summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2021-03-14 07:06:18 +0300
committereug-vs <eug-vs@keemail.me>2021-03-14 07:06:18 +0300
commitac9698ea0de17ab2d1fbfafead0f33295a402e28 (patch)
tree839767b2c34b5be47223274bf47ee1aa42c83cd8 /src
parent1b86dcef9fd537db800e0df2c2f3889ffbc69723 (diff)
downloadcommercel-api-ac9698ea0de17ab2d1fbfafead0f33295a402e28.tar.gz
feat: add Contractors service
Diffstat (limited to 'src')
-rw-r--r--src/models/contractor/contractor.model.ts4
-rw-r--r--src/models/contractor/contractor.schema.ts18
-rw-r--r--src/services/contractors.service.ts10
-rw-r--r--src/services/index.ts4
-rw-r--r--src/services/products.service.ts (renamed from src/services/products/products.service.ts)2
5 files changed, 36 insertions, 2 deletions
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<ContractorSchema, Model<ContractorSchema>>('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/products.service.ts b/src/services/products.service.ts
index 6461dae..f3ae2b6 100644
--- a/src/services/products/products.service.ts
+++ b/src/services/products.service.ts
@@ -1,6 +1,6 @@
import { Application } from '@feathersjs/express';
import service from 'feathers-mongoose';
-import Model from '../../models/product/product.model';
+import Model from '../models/product/product.model';
const Products = service({ Model });