Add a simple receive service based on feathers-sequelize
This commit is contained in:
parent
13bd07e810
commit
05fe7ceb91
|
@ -2,6 +2,7 @@
|
|||
"host": "localhost",
|
||||
"port": 3030,
|
||||
"public": "../public/",
|
||||
"postgres": "postgres://postgres:jenkinsuplink@db:5432/uplink_development",
|
||||
"paginate": {
|
||||
"default": 10,
|
||||
"max": 50
|
||||
|
|
|
@ -4,13 +4,16 @@ import fs from 'fs';
|
|||
import path from 'path';
|
||||
import Sequelize from 'sequelize';
|
||||
|
||||
import logger from '../logger';
|
||||
|
||||
const basename = path.basename(__filename);
|
||||
const env = process.env.NODE_ENV || 'development';
|
||||
const config = require(__dirname + '/../config/database')[env];
|
||||
|
||||
const config = require(__dirname + '/../../config/database')[env];
|
||||
|
||||
const db : any = {};
|
||||
const sequelize = new Sequelize(config.database, config.username, config.password, config);
|
||||
const sequelize = new Sequelize(config.url, {
|
||||
dialect: 'postgres',
|
||||
});
|
||||
|
||||
fs
|
||||
.readdirSync(__dirname)
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
import receive from './receive';
|
||||
|
||||
export default (app) => {
|
||||
app.configure(receive);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import { HooksObject } from '@feathersjs/feathers';
|
||||
|
||||
export const receiveHooks : HooksObject = {
|
||||
before: {
|
||||
all: [],
|
||||
find: [],
|
||||
get: [],
|
||||
create: [],
|
||||
update: [],
|
||||
patch: [],
|
||||
remove: []
|
||||
},
|
||||
after: {},
|
||||
error: {},
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* The /receive service is responsible receiving the data POSTed from the
|
||||
* Jenkins instances and storing it in the database
|
||||
*/
|
||||
|
||||
import db from '../models';
|
||||
import Event from '../models/event';
|
||||
import service from 'feathers-sequelize';
|
||||
import { DataTypes } from 'sequelize';
|
||||
import { receiveHooks } from './receive.hooks';
|
||||
|
||||
export default (app) => {
|
||||
const Model : any = Event(db.sequelize, db.sequelize.Sequelize);
|
||||
app.use('/receive', service({ Model }));
|
||||
app.service('receive').hooks(receiveHooks);
|
||||
};
|
Loading…
Reference in New Issue