Compare commits
No commits in common. "10b5207f9a8c6507ec60468752993910f154bb0e" and "2ede62bcd82769e0d145f07501a5e0a7f8cc2973" have entirely different histories.
10b5207f9a
...
2ede62bcd8
@ -1,37 +0,0 @@
|
||||
const router = require('express').Router()
|
||||
const {MasterModel} = require('./model/master')
|
||||
|
||||
router.post('/master', async (req, res,next) => {
|
||||
|
||||
const {name, phone} = req.body
|
||||
|
||||
if (!name || !phone ){
|
||||
throw new Error('Enter name and phone')
|
||||
}
|
||||
try {
|
||||
const master = await MasterModel.create({name, phone})
|
||||
res.status(200).send({success: true, body: master})
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
router.get('/masters', async (req, res,next) => {
|
||||
try {
|
||||
const master = await MasterModel.find({})
|
||||
res.status(200).send({success: true, body: master})
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
router.get('/orders', (req, res) => {
|
||||
res
|
||||
.status(200)
|
||||
.send(require(`./json/arm-orders/success.json`))
|
||||
})
|
||||
|
||||
module.exports = router
|
@ -1,8 +1,15 @@
|
||||
const router = require('express').Router()
|
||||
const armRouter = require('./arm')
|
||||
|
||||
router.get('/arm/masters', (req, res) => {
|
||||
res
|
||||
.status(200)
|
||||
.send(require("./json/arm-masters/success.json"))
|
||||
})
|
||||
|
||||
router.use('/arm', armRouter)
|
||||
|
||||
router.get('/arm/orders', (req, res) => {
|
||||
res
|
||||
.status(200)
|
||||
.send(require(`./json/arm-orders/success.json`))
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
|
@ -1,20 +0,0 @@
|
||||
const { Schema, model } = require('mongoose')
|
||||
|
||||
const schema = new Schema({
|
||||
name: {type: String, required: true},
|
||||
phone: {type: String, required: true,unique: true,},
|
||||
created: {
|
||||
type: Date, default: () => new Date().toISOString(),
|
||||
},
|
||||
})
|
||||
|
||||
schema.set('toJSON', {
|
||||
virtuals: true,
|
||||
versionKey: false,
|
||||
})
|
||||
|
||||
schema.virtual('id').get(function () {
|
||||
return this._id.toHexString()
|
||||
})
|
||||
|
||||
exports.MasterModel = model('dry-wash-master', schema)
|
@ -1,30 +0,0 @@
|
||||
const { Schema, model } = require('mongoose')
|
||||
|
||||
const schema = new Schema({
|
||||
startWashTime: {type: String, required: true},
|
||||
endWashTime: {type: String, required: true},
|
||||
orderDate: {type: String, required: true},
|
||||
location: {type: String, required: true},
|
||||
phone: {type: String, required: true},
|
||||
status: {type: String, required: true},
|
||||
carNumber: {type: String, required: true},
|
||||
created: {
|
||||
type: Date, default: () => new Date().toISOString(),
|
||||
},
|
||||
updated: {
|
||||
type: Date, default: () => new Date().toISOString(),
|
||||
},
|
||||
master: {type: Schema.Types.ObjectId, ref: 'dry-wash-master'},
|
||||
notes: String,
|
||||
})
|
||||
|
||||
schema.set('toJSON', {
|
||||
virtuals: true,
|
||||
versionKey: false,
|
||||
})
|
||||
|
||||
schema.virtual('id').get(function () {
|
||||
return this._id.toHexString()
|
||||
})
|
||||
|
||||
exports.OrderModel = model('dry-wash-order', schema)
|
@ -1,60 +0,0 @@
|
||||
{
|
||||
"info": {
|
||||
"_postman_id": "e91fbcf7-3c7b-420d-a49e-4dbb6199c14a",
|
||||
"name": "dry-wash",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
||||
"_exporter_id": "27705820"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "arm",
|
||||
"item": [
|
||||
{
|
||||
"name": "create master",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"name\":\"Anton\",\n \"phone\": \"89172420577\"\n}",
|
||||
"options": {
|
||||
"raw": {
|
||||
"language": "json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{host}}/arm/master",
|
||||
"host": [
|
||||
"{{host}}"
|
||||
],
|
||||
"path": [
|
||||
"arm",
|
||||
"master"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "get masters",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{host}}/arm/masters",
|
||||
"host": [
|
||||
"{{host}}"
|
||||
],
|
||||
"path": [
|
||||
"arm",
|
||||
"masters"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user