diff --git a/.idea/API.iml b/.idea/API.iml index c956989..d1fe0c4 100644 --- a/.idea/API.iml +++ b/.idea/API.iml @@ -1,7 +1,11 @@ - + + + + + diff --git a/.idea/dictionaries/VLE2FE.xml b/.idea/dictionaries/VLE2FE.xml index a241715..5e9cd2d 100644 --- a/.idea/dictionaries/VLE2FE.xml +++ b/.idea/dictionaries/VLE2FE.xml @@ -1,37 +1,53 @@ + adminnew + adminxx akro amodel anwendungsbeschränkt + apidoc + arora batchgranulate bcrypt bnpd + bsontype cfenv + changeadmin colordesignatiomsuppl colordesignationsuppl contentin + crastin definma dfopdb dosiergeschw dpts einspritzgeschw + errback frameguard + frankland functionlink glassfibrecontent isin janedoe + johndoe johnnydoe kfingew latamid lati lyucy materialnumber + nvmrc + oldpass + opblock pagesize + pagesizes pnach preaged + puneet reinforcementmaterial reinforcingmaterial + rewatch samplenumber sdpt signalviolet @@ -42,7 +58,10 @@ stringin testcomment ultramid + unknownroute vorgealtert + xcopy + yankov \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 285ddb5..c2536e0 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -1,8 +1,25 @@ \ No newline at end of file diff --git a/README.md b/README.md index a1fbc4d..522a5a8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Digital fingerprint of plastics - API +# DeFinMa - API This is the API to access the database of the digital fingerprint of plastics project. diff --git a/api/api.yaml b/api/api.yaml index 45be8c4..d85acc7 100644 --- a/api/api.yaml +++ b/api/api.yaml @@ -1,6 +1,5 @@ openapi: 3.0.2 - info: title: Digital fingerprint of plastics - API version: 1.0.0 diff --git a/src/api.ts b/src/api.ts index 8988cf1..80ab5a8 100644 --- a/src/api.ts +++ b/src/api.ts @@ -67,6 +67,7 @@ function resolveXDoc (doc) { // resolve x-doc properties recursively // templates +// noinspection LongLine const htmlTplString = ` diff --git a/src/customTypes/express.ts b/src/customTypes/express.ts index 361c961..ce89d49 100644 --- a/src/customTypes/express.ts +++ b/src/customTypes/express.ts @@ -10,7 +10,7 @@ /* =================== USAGE =================== import * as express from "express"; - var app = express(); + let app = express(); =============================================== */ @@ -29,40 +29,44 @@ declare function e(): core.Express; declare namespace e { /** - * This is a built-in middleware function in Express. It parses incoming requests with JSON payloads and is based on body-parser. + * This is a built-in middleware function in Express. It parses incoming requests with JSON payloads and is based on + * body-parser. * @since 4.16.0 */ - var json: typeof bodyParser.json; + let json: typeof bodyParser.json; /** - * This is a built-in middleware function in Express. It parses incoming requests with Buffer payloads and is based on body-parser. + * This is a built-in middleware function in Express. It parses incoming requests with Buffer payloads and is based + * on body-parser. * @since 4.17.0 */ - var raw: typeof bodyParser.raw; + let raw: typeof bodyParser.raw; /** - * This is a built-in middleware function in Express. It parses incoming requests with text payloads and is based on body-parser. + * This is a built-in middleware function in Express. It parses incoming requests with text payloads and is based on + * body-parser. * @since 4.17.0 */ - var text: typeof bodyParser.text; + let text: typeof bodyParser.text; /** * These are the exposed prototypes. */ - var application: Application; - var request: Request; - var response: Response; + let application: Application; + let request: Request; + let response: Response; /** * This is a built-in middleware function in Express. It serves static files and is based on serve-static. */ - var static: typeof serveStatic; + let static: typeof serveStatic; /** - * This is a built-in middleware function in Express. It parses incoming requests with urlencoded payloads and is based on body-parser. + * This is a built-in middleware function in Express. It parses incoming requests with urlencoded payloads and is + * based on body-parser. * @since 4.16.0 */ - var urlencoded: typeof bodyParser.urlencoded; + let urlencoded: typeof bodyParser.urlencoded; /** * This is a built-in middleware function in Express. It parses incoming request query parameters. @@ -95,7 +99,8 @@ declare namespace e { interface Application extends core.Application { } interface CookieOptions extends core.CookieOptions { } interface Errback extends core.Errback { } - interface ErrorRequestHandler

+ interface ErrorRequestHandler

extends core.ErrorRequestHandler { } interface Express extends core.Express { } interface Handler extends core.Handler { } @@ -105,8 +110,10 @@ declare namespace e { interface IRouterMatcher extends core.IRouterMatcher { } interface MediaType extends core.MediaType { } interface NextFunction extends core.NextFunction { } - interface Request

extends core.Request { } - interface RequestHandler

extends core.RequestHandler { } + interface Request

extends core.Request { } + interface RequestHandler

extends core.RequestHandler { } interface RequestParamHandler extends core.RequestParamHandler { } export interface Response extends core.Response { } interface Router extends core.Router { } diff --git a/src/routes/material.spec.ts b/src/routes/material.spec.ts index 0f362ae..1bbae13 100644 --- a/src/routes/material.spec.ts +++ b/src/routes/material.spec.ts @@ -3,7 +3,6 @@ import MaterialModel from '../models/material'; import MaterialGroupModel from '../models/material_groups'; import MaterialSupplierModel from '../models/material_suppliers'; import TestHelper from "../test/helper"; -import globals from '../globals'; describe('/material', () => { diff --git a/src/routes/sample.ts b/src/routes/sample.ts index 4d84d1d..ab8ff1c 100644 --- a/src/routes/sample.ts +++ b/src/routes/sample.ts @@ -581,27 +581,13 @@ router.get('/sample/number/:number', (req, res, next) => { router.put('/sample/restore/' + IdValidate.parameter(), (req, res, next) => { if (!req.auth(res, ['dev', 'admin'], 'basic')) return; - SampleModel.findByIdAndUpdate(req.params.id, {status: globals.status.new}).log(req).lean().exec((err, data) => { - if (err) return next(err); - - if (!data) { - return res.status(404).json({status: 'Not found'}); - } - res.json({status: 'OK'}); - }); + setStatus(globals.status.new, req, res, next); }); router.put('/sample/validate/' + IdValidate.parameter(), (req, res, next) => { if (!req.auth(res, ['dev', 'admin'], 'basic')) return; - SampleModel.findByIdAndUpdate(req.params.id, {status: globals.status.val}).log(req).lean().exec((err, data) => { - if (err) return next(err); - if (!data) { - return res.status(404).json({status: 'Not found'}); - } - - res.json({status: 'OK'}); - }); + setStatus(globals.status.val, req, res, next); }); router.post('/sample/new', async (req, res, next) => { @@ -899,4 +885,15 @@ async function sampleReturn (sampleData, req, res, next) { else { res.status(404).json({status: 'Not found'}); } +} + +function setStatus (status, req, res, next) { + SampleModel.findByIdAndUpdate(req.params.id, {status}).log(req).lean().exec((err, data) => { + if (err) return next(err); + + if (!data) { + return res.status(404).json({status: 'Not found'}); + } + res.json({status: 'OK'}); + }); } \ No newline at end of file diff --git a/src/routes/validate/id.ts b/src/routes/validate/id.ts index e52e688..e0d8362 100644 --- a/src/routes/validate/id.ts +++ b/src/routes/validate/id.ts @@ -1,7 +1,10 @@ import Joi from 'joi'; export default class IdValidate { - private static id = Joi.string().pattern(new RegExp('[0-9a-f]{24}')).length(24).messages({'string.pattern.base': 'Invalid object id'}); + private static id = Joi.string() + .pattern(new RegExp('[0-9a-f]{24}')) + .length(24) + .messages({'string.pattern.base': 'Invalid object id'}); static get () { // return joi validation return this.id; @@ -17,7 +20,8 @@ export default class IdValidate { static stringify (data) { // convert all ObjectID objects to plain strings Object.keys(data).forEach(key => { - if (data[key] !== null && data[key].hasOwnProperty('_bsontype') && data[key]._bsontype === 'ObjectID') { // stringify id + // stringify id + if (data[key] !== null && data[key].hasOwnProperty('_bsontype') && data[key]._bsontype === 'ObjectID') { data[key] = data[key].toString(); } else if (typeof data[key] === 'object' && data[key] !== null) { // deeper into recursion diff --git a/src/routes/validate/parameters.ts b/src/routes/validate/parameters.ts index 8fcc63b..8f24c52 100644 --- a/src/routes/validate/parameters.ts +++ b/src/routes/validate/parameters.ts @@ -1,7 +1,8 @@ import Joi from 'joi'; export default class ParametersValidate { - static input (data, parameters, param) { // data to validate, parameters from template, param: 'new', 'change', 'null'(null values are allowed) + // data to validate, parameters from template, param: 'new', 'change', 'null'(null values are allowed) + static input (data, parameters, param) { let joiObject = {}; parameters.forEach(parameter => { if (parameter.range.hasOwnProperty('values')) { // append right validation method according to parameter diff --git a/static/intro-presentation/assets/styles.css b/static/intro-presentation/assets/styles.css index 3a4aa18..8eba113 100644 --- a/static/intro-presentation/assets/styles.css +++ b/static/intro-presentation/assets/styles.css @@ -23,7 +23,6 @@ .go-btn button { color: #ffffff; border-color: #008ecf; - background: linear-gradient(to bottom, #005691 0%, #005691 50%, #008ecf 50%, #008ecf 100%); border-width: 1px; line-height: 40px; padding: 30px 60px; @@ -33,7 +32,7 @@ text-align: center; cursor: pointer; transition: border, background cubic-bezier(0.38, 0.04, 0.35, 0.96) 600ms; - background-position: 0 0; + background: linear-gradient(to bottom, #005691 0%, #005691 50%, #008ecf 50%, #008ecf 100%) 0 0; background-size: 100% 200%; } diff --git a/static/intro-presentation/assets/styles_global.css b/static/intro-presentation/assets/styles_global.css index 141c069..1bfa1d7 100644 --- a/static/intro-presentation/assets/styles_global.css +++ b/static/intro-presentation/assets/styles_global.css @@ -31,7 +31,7 @@ color: #000; position: absolute; bottom: 10px; - font-size: 8.5px; + font-size: 9px; left: 39px; } diff --git a/static/intro-presentation/index.html b/static/intro-presentation/index.html index 4653f9c..c90b410 100644 --- a/static/intro-presentation/index.html +++ b/static/intro-presentation/index.html @@ -1,5 +1,5 @@ - + DeFinMaDB - Introduction @@ -248,7 +248,7 @@ layout: true class: content, theme-dark-green layout: true -# Thats all +# That's all --- @@ -264,7 +264,7 @@ layout: true