From ac9698ea0de17ab2d1fbfafead0f33295a402e28 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 14 Mar 2021 07:06:18 +0300 Subject: feat: add Contractors service --- src/models/contractor/contractor.model.ts | 4 ++++ src/models/contractor/contractor.schema.ts | 18 ++++++++++++++++++ src/services/contractors.service.ts | 10 ++++++++++ src/services/index.ts | 4 +++- src/services/products.service.ts | 10 ++++++++++ src/services/products/products.service.ts | 10 ---------- 6 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 src/models/contractor/contractor.model.ts create mode 100644 src/models/contractor/contractor.schema.ts create mode 100644 src/services/contractors.service.ts create mode 100644 src/services/products.service.ts delete mode 100644 src/services/products/products.service.ts (limited to 'src') diff --git a/src/models/contractor/contractor.model.ts b/src/models/contractor/contractor.model.ts new file mode 100644 index 0000000..32c14f4 --- /dev/null +++ b/src/models/contractor/contractor.model.ts @@ -0,0 +1,4 @@ +import { Model, model } from 'mongoose'; +import { ContractorSchema, contractorSchema } from './contractor.schema'; + +export default model>('Contractor', contractorSchema); diff --git a/src/models/contractor/contractor.schema.ts b/src/models/contractor/contractor.schema.ts new file mode 100644 index 0000000..e3f7de6 --- /dev/null +++ b/src/models/contractor/contractor.schema.ts @@ -0,0 +1,18 @@ +import { Document, Schema, Types } from 'mongoose'; + +export interface ContractorSchema extends Document { + name: string; + fullName: string; + vatId: string; + type: string; + debt: number; +} + +export const contractorSchema = new Schema({ + name: String, + fullName: String, + vatId: String, + type: String, + debt: Number +}, { timestamps: true }); + diff --git a/src/services/contractors.service.ts b/src/services/contractors.service.ts new file mode 100644 index 0000000..a5b3f59 --- /dev/null +++ b/src/services/contractors.service.ts @@ -0,0 +1,10 @@ +import { Application } from '@feathersjs/express'; +import service from 'feathers-mongoose'; +import Model from '../models/contractor/contractor.model'; + +const contractors = service({ Model }); + +export default (app: Application): void => { + app.use('/contractors', contractors); +}; + diff --git a/src/services/index.ts b/src/services/index.ts index d35ac27..9b3511b 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,8 +1,10 @@ import { Application } from '@feathersjs/express'; -import Products from './products/products.service'; +import Products from './products.service'; +import Contractors from './contractors.service'; export default (app: Application): void => { app.configure(Products); + app.configure(Contractors); app.get('/ping', (req, res) => res.send('pong')); }; diff --git a/src/services/products.service.ts b/src/services/products.service.ts new file mode 100644 index 0000000..f3ae2b6 --- /dev/null +++ b/src/services/products.service.ts @@ -0,0 +1,10 @@ +import { Application } from '@feathersjs/express'; +import service from 'feathers-mongoose'; +import Model from '../models/product/product.model'; + +const Products = service({ Model }); + +export default (app: Application): void => { + app.use('/products', Products); +}; + diff --git a/src/services/products/products.service.ts b/src/services/products/products.service.ts deleted file mode 100644 index 6461dae..0000000 --- a/src/services/products/products.service.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Application } from '@feathersjs/express'; -import service from 'feathers-mongoose'; -import Model from '../../models/product/product.model'; - -const Products = service({ Model }); - -export default (app: Application): void => { - app.use('/products', Products); -}; - -- cgit v1.2.3