Archived
2

added TODOs, improved password validation

This commit is contained in:
VLE2FE 2020-05-26 09:07:01 +02:00
parent 5209410009
commit aef2753229
9 changed files with 30 additions and 11 deletions

View File

@ -4,7 +4,7 @@ import oasParser from '@apidevtools/swagger-parser';
// modifies the normal swagger-ui-express package
// usage: app.use('/api', api.serve(), api.setup());
// usage: app.use('/api-doc', api.serve(), api.setup());
// the paths property can be split using allOf
// further route documentation can be included in the x-doc property

View File

@ -5,7 +5,12 @@ import mongoSanitize from 'mongo-sanitize';
import api from './api';
import db from './db';
// TODO: changelog
// TODO: check executing index.js/move everything needed into dist
// TODO: One condition per sample
// TODO: validation: VZ, Humidity: min/max value, DPT: filename
// TODO: condition values not needed on initial add
// TODO: add multiple samples at once
// tell if server is running in debug or production environment
console.info(process.env.NODE_ENV === 'production' ? '===== PRODUCTION =====' : process.env.NODE_ENV === 'test' ? '' :'===== DEVELOPMENT =====');
@ -44,19 +49,19 @@ app.use((req, res, next) => { // no database connection error
app.use(require('./helpers/authorize')); // handle authentication
// require routes
app.use('/', require('./routes/root'));
app.use('/', require('./routes/sample'));
app.use('/', require('./routes/material'));
app.use('/', require('./routes/template'));
app.use('/', require('./routes/user'));
app.use('/', require('./routes/condition'));
app.use('/', require('./routes/measurement'));
app.use('/api', require('./routes/root'));
app.use('/api', require('./routes/sample'));
app.use('/api', require('./routes/material'));
app.use('/api', require('./routes/template'));
app.use('/api', require('./routes/user'));
app.use('/api', require('./routes/condition'));
app.use('/api', require('./routes/measurement'));
// static files
app.use('/static', express.static('static'));
// Swagger UI
app.use('/api', api.serve(), api.setup());
app.use('/api-doc', api.serve(), api.setup());
app.use((req, res) => { // 404 error handling
res.status(404).json({status: 'Not found'});

View File

@ -2,6 +2,10 @@ import should from 'should/as-function';
import ConditionModel from '../models/condition';
import TestHelper from "../test/helper";
// TODO: adding conditions allowed only for m/a
// TODO: deleted data only visible for m/a
// TODO: restore deleted
// TODO: remove number_prefix
describe('/condition', () => {
let server;

View File

@ -3,6 +3,8 @@ import _ from 'lodash';
import MaterialModel from '../models/material';
import TestHelper from "../test/helper";
// TODO: color name must be unique to get color number
// TODO: separate supplier/ material name into own collections
describe('/material', () => {
let server;

View File

@ -2,6 +2,9 @@ import should from 'should/as-function';
import MeasurementModel from '../models/measurement';
import TestHelper from "../test/helper";
// TODO: allow empty values
describe('/measurement', () => {
let server;
before(done => TestHelper.before(done));

View File

@ -4,6 +4,9 @@ import NoteModel from '../models/note';
import NoteFieldModel from '../models/note_field';
import TestHelper from "../test/helper";
// TODO: generate output for ML in format DPT -> data, implement filtering, field selection
// TODO: write script for data import
// TODO: delete everything (measurements, condition) with sample
describe('/sample', () => {
let server;

View File

@ -4,6 +4,7 @@ import TemplateTreatmentModel from '../models/treatment_template';
import TemplateMeasurementModel from '../models/measurement_template';
import TestHelper from "../test/helper";
// TODO: do not allow usage of old templates for new samples
describe('/template', () => {
let server;

View File

@ -2,6 +2,7 @@ import should from 'should/as-function';
import UserModel from '../models/user';
import TestHelper from "../test/helper";
// TODO: reject usernames containing admin, etc.
describe('/user', () => {
let server;

View File

@ -16,7 +16,7 @@ export default class UserValidate { // validate input for user
.max(128),
pass: Joi.string()
.pattern(new RegExp('^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!"#%&\'()*+,-.\\/:;<=>?@[\\]^_`{|}~])(?=\\S+$).{8,}$'))
.pattern(/^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!"#%&'()*+,-.\/:;<=>?@[\]^_`{|}~])(?=\S+$)[a-zA-Z0-9!"#%&'()*+,\-.\/:;<=>?@[\]^_`{|}~]{8,}$/)
.max(128),
level: Joi.string()