Skip to content

Instantly share code, notes, and snippets.

@GhuronZhan
Last active January 30, 2019 10:05
Show Gist options
  • Save GhuronZhan/562f7c006c38812008d0e770de43fec9 to your computer and use it in GitHub Desktop.
Save GhuronZhan/562f7c006c38812008d0e770de43fec9 to your computer and use it in GitHub Desktop.
Feathers-plus issues
{
"options": {
"ver": "1.0.0",
"inspectConflicts": false,
"semicolons": true,
"freeze": [],
"ts": true
},
"app": {
"environmentsAllowingSeedData": "staging",
"seedData": true,
"name": "test-fia",
"description": "Project test-fia",
"src": "src",
"packager": "npm@>= 3.0.0",
"providers": [
"rest",
"socketio"
]
},
"services": {
"users": {
"name": "users",
"nameSingular": "user",
"subFolder": "",
"fileName": "users",
"adapter": "sequelize",
"path": "/users",
"isAuthEntity": true,
"requiresAuth": true,
"graphql": true
},
"roles": {
"name": "roles",
"nameSingular": "role",
"subFolder": "",
"fileName": "roles",
"adapter": "sequelize",
"path": "/roles",
"isAuthEntity": false,
"requiresAuth": true,
"graphql": true
},
"teams": {
"name": "teams",
"nameSingular": "team",
"subFolder": "",
"fileName": "teams",
"adapter": "sequelize",
"path": "/teams",
"isAuthEntity": false,
"requiresAuth": true,
"graphql": true
}
},
"hooks": {},
"authentication": {
"strategies": [
"local"
],
"entity": "users"
},
"connections": {
"sequelize": {
"database": "mysql",
"adapter": "sequelize",
"connectionString": "mysql://root:root@localhost:3306/fia_default"
}
}
}
/* tslint:disable no-console */
// Start the server. (Can be re-generated.)
// !code: preface // !end
import logger from './logger';
import app from './app';
import seedData from './seed-data';
// !code: imports // !end
// !code: init // !end
const port = app.get('port');
const server = app.listen(port);
// !code: init2 // !end
process.on('unhandledRejection', (reason, p) => {
// !<DEFAULT> code: unhandled_rejection_log
logger.error('Unhandled Rejection at: Promise ', p, reason);
// !end
// !code: unhandled_rejection // !end
});
server.on('listening', async () => {
// !<DEFAULT> code: listening_log
logger.info('Feathers application started on http://%s:%d', app.get('host'), port);
// !end
// !code: listening // !end
await seedData(app);
// !code: listening1 // !end
});
// !code: funcs // !end
// !code: end // !end
{
"name": "test-fia",
"description": "Project test-fia",
"version": "0.0.0",
"homepage": "",
"main": "src",
"keywords": [
"feathers"
],
"author": {
"name": "Benoit Barbaud",
"email": "b.barbaud@superdev.fr"
},
"contributors": [],
"bugs": {},
"directories": {
"lib": "src",
"test": "test/"
},
"engines": {
"node": "^10.0.0",
"npm": ">= 3.0.0"
},
"scripts": {
"test": "npm run tslint && npm run mocha",
"test:all": "npm run tslint && cross-env NODE_ENV=staging npm run mocha",
"tslint": "tslint -p tsconfig.json -c tslint.json && tslint -p tsconfig.test.json -c tslint.json",
"dev": "nodemon src/index.ts",
"dev:seed": "nodemon src/index.ts --seed",
"start": "ts-node --files src/",
"start:seed": "cross-env NODE_ENV=staging ts-node --seed --files src/",
"mocha": "ts-mocha -p tsconfig.test.json \"test/**/*.test.ts\" --timeout 10000 --exit",
"compile": "tsc -p tsconfig.json"
},
"dependencies": {
"@feathers-plus/test-utils": "^0.3.5",
"@feathersjs/authentication": "^2.1.15",
"@feathersjs/authentication-jwt": "^2.0.9",
"@feathersjs/authentication-local": "^1.2.9",
"@feathersjs/configuration": "^2.0.6",
"@feathersjs/errors": "^3.3.6",
"@feathersjs/express": "^1.3.1",
"@feathersjs/feathers": "^3.3.1",
"@feathersjs/socketio": "^3.2.9",
"ajv": "^5.5.2",
"compression": "^1.7.3",
"cors": "^2.8.5",
"cross-env": "^5.2.0",
"feathers-hooks-common": "^4.20.2",
"feathers-sequelize": "^3.1.3",
"helmet": "^3.15.0",
"lodash.merge": "^4.6.1",
"mysql2": "^1.6.4",
"sequelize": "^4.42.0",
"serve-favicon": "^2.5.0",
"winston": "^3.1.0"
},
"devDependencies": {
"@types/compression": "0.0.36",
"@types/cors": "^2.8.4",
"@types/feathersjs__authentication": "^2.1.2",
"@types/feathersjs__authentication-jwt": "^1.0.5",
"@types/feathersjs__authentication-local": "^1.0.3",
"@types/feathersjs__configuration": "^1.0.1",
"@types/feathersjs__errors": "^3.2.1",
"@types/feathersjs__express": "^1.1.4",
"@types/feathersjs__feathers": "^3.1.1",
"@types/feathersjs__socketio": "^3.0.3",
"@types/helmet": "0.0.40",
"@types/lodash.merge": "^4.6.4",
"@types/mocha": "^5.2.5",
"@types/request-promise": "^4.1.42",
"@types/sequelize": "^4.27.34",
"@types/serve-favicon": "^2.2.30",
"@types/winston": "^2.4.4",
"mocha": "^5.2.0",
"nodemon": "^1.18.9",
"request": "^2.88.0",
"request-promise": "^4.2.2",
"ts-mocha": "^2.0.0",
"ts-node": "^7.0.1",
"tslint": "^5.12.1",
"typescript": "^3.2.4"
}
}
// Define the Feathers schema for service `roles`. (Can be re-generated.)
// !code: imports // !end
// !code: init // !end
// Define the model using JSON-schema
let schema = {
// !<DEFAULT> code: schema_header
title: 'Roles',
description: 'Roles database.',
// !end
// !code: schema_definitions // !end
// Required fields.
required: [
// !code: schema_required
'name'
// !end
],
// Fields with unique values.
uniqueItemProperties: [
// !code: schema_unique // !end
],
// Fields in the model.
properties: {
// !code: schema_properties
id: { type: 'ID' },
name: {}
// !end
},
// !code: schema_more // !end
};
// Define optional, non-JSON-schema extensions.
let extensions = {
// GraphQL generation.
graphql: {
// !code: graphql_header
name: 'Role',
service: {
sort: { id: 1 },
},
// sql: {
// sqlTable: 'Roles',
// uniqueKey: 'id',
// sqlColumn: {
// __authorId__: '__author_id__',
// },
// },
// !end
discard: [
// !code: graphql_discard // !end
],
add: {
// !<DEFAULT> code: graphql_add
// __author__: { type: '__User__!', args: false, relation: { ourTable: '__authorId__', otherTable: 'id' } },
// !end
},
// !code: graphql_more // !end
},
};
// !code: more // !end
let moduleExports = {
schema,
extensions,
// !code: moduleExports // !end
};
// !code: exports // !end
export default moduleExports;
// !code: funcs // !end
// !code: end // !end
/* tslint:disable:quotemark */
// Defines Sequelize model for service `roles`. (Can be re-generated.)
import merge from 'lodash.merge';
import Sequelize, { DefineAttributes } from 'sequelize';
// tslint:disable-next-line:no-unused-variable
const DataTypes = (Sequelize as any).DataTypes as Sequelize.DataTypes;
// !code: imports // !end
// !code: init // !end
let moduleExports = merge({},
// !<DEFAULT> code: sequelize_model
{
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
name: {
type: DataTypes.TEXT,
allowNull: false
}
} as DefineAttributes,
// !end
// !code: moduleExports // !end
);
// !code: exports // !end
export default moduleExports;
// !code: funcs // !end
// !code: end // !end
// sequelize.ts - Sequelize adapter (other than SQL server)
import { App } from './app.interface';
import Sequelize from 'sequelize';
let { Op } = Sequelize;
// !code: imports // !end
// !code: init // !end
const operatorsAliases = {
$eq: Op.eq,
$ne: Op.ne,
$gte: Op.gte,
$gt: Op.gt,
$lte: Op.lte,
$lt: Op.lt,
$not: Op.not,
$in: Op.in,
$notIn: Op.notIn,
$is: Op.is,
$like: Op.like,
$notLike: Op.notLike,
$iLike: Op.iLike,
$notILike: Op.notILike,
$regexp: Op.regexp,
$notRegexp: Op.notRegexp,
$iRegexp: Op.iRegexp,
$notIRegexp: Op.notIRegexp,
$between: Op.between,
$notBetween: Op.notBetween,
$overlap: Op.overlap,
$contains: Op.contains,
$contained: Op.contained,
$adjacent: Op.adjacent,
$strictLeft: Op.strictLeft,
$strictRight: Op.strictRight,
$noExtendRight: Op.noExtendRight,
$noExtendLeft: Op.noExtendLeft,
$and: Op.and,
$or: Op.or,
$any: Op.any,
$all: Op.all,
$values: Op.values,
$col: Op.col
};
export default function (app: App) {
let connectionString = app.get('mysql');
let sequelize = new Sequelize(connectionString, {
dialect: 'mysql',
logging: false,
operatorsAliases,
define: {
freezeTableName: true
}
});
let oldSetup = app.setup;
// !code: func_init // !end
app.set('sequelizeClient', sequelize);
app.setup = function (...args: any[]) {
let result = oldSetup.apply(this, args);
// !code: func_init // !end
// Set up data relationships
const models = sequelize.models;
Object.keys(models).forEach(name => {
if ('associate' in models[name]) {
models[name].associate!(models);
}
});
// Sync to the database
sequelize.sync();
// !code: func_return // !end
return result;
};
// !code: more // !end
}
// !code: funcs // !end
// !code: end // !end
// Define the Feathers schema for service `teams`. (Can be re-generated.)
// !code: imports // !end
// !code: init // !end
// Define the model using JSON-schema
let schema = {
// !<DEFAULT> code: schema_header
title: 'Teams',
description: 'Teams database.',
// !end
// !code: schema_definitions // !end
// Required fields.
required: [
// !code: schema_required
'name',
'members'
// !end
],
// Fields with unique values.
uniqueItemProperties: [
// !code: schema_unique // !end
],
// Fields in the model.
properties: {
// !code: schema_properties
id: { type: 'ID' },
name: {},
members: {
type: 'array',
items: { type: 'ID' }
}
// !end
},
// !code: schema_more // !end
};
// Define optional, non-JSON-schema extensions.
let extensions = {
// GraphQL generation.
graphql: {
// !code: graphql_header
name: 'Team',
service: {
sort: { id: 1 },
},
// sql: {
// sqlTable: 'Teams',
// uniqueKey: 'id',
// sqlColumn: {
// __authorId__: '__author_id__',
// },
// },
// !end
discard: [
// !code: graphql_discard // !end
],
add: {
// !<DEFAULT> code: graphql_add
// __author__: { type: '__User__!', args: false, relation: { ourTable: '__authorId__', otherTable: 'id' } },
// !end
},
// !code: graphql_more // !end
},
};
// !code: more // !end
let moduleExports = {
schema,
extensions,
// !code: moduleExports // !end
};
// !code: exports // !end
export default moduleExports;
// !code: funcs // !end
// !code: end // !end
/* tslint:disable:quotemark */
// Defines Sequelize model for service `teams`. (Can be re-generated.)
import merge from 'lodash.merge';
import Sequelize, { DefineAttributes } from 'sequelize';
// tslint:disable-next-line:no-unused-variable
const DataTypes = (Sequelize as any).DataTypes as Sequelize.DataTypes;
// !code: imports // !end
// !code: init // !end
let moduleExports = merge({},
// !<DEFAULT> code: sequelize_model
{
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
name: {
type: DataTypes.TEXT,
allowNull: false
},
members: {
type: DataTypes.JSONB,
allowNull: false
}
} as DefineAttributes,
// !end
// !code: moduleExports // !end
);
// !code: exports // !end
export default moduleExports;
// !code: funcs // !end
// !code: end // !end
{
"include": [
"src/index.ts",
"src/typings.d.ts"
],
"compilerOptions": {
/* Basic Options */
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": [ /* Specify library files to be included in the compilation. */
"es2017",
"esnext.asynciterable"
],
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./compiled", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
"typeRoots": [ /* List of folders to include type definitions from. */
"node_modules/@types"
],
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
}
}
// Define the Feathers schema for service `users`. (Can be re-generated.)
// !code: imports // !end
// !code: init // !end
// Define the model using JSON-schema
let schema = {
// !<DEFAULT> code: schema_header
title: 'Users',
description: 'Users database.',
// !end
// !code: schema_definitions // !end
// Required fields.
required: [
// !code: schema_required
'email',
'firstName',
'lastName',
'roleId'
// !end
],
// Fields with unique values.
uniqueItemProperties: [
// !code: schema_unique // !end
],
// Fields in the model.
properties: {
// !code: schema_properties
id: { type: 'ID' },
email: {},
firstName: {},
lastName: {},
password: {},
roleId: { type: 'ID' }
// !end
},
// !code: schema_more // !end
};
// Define optional, non-JSON-schema extensions.
let extensions = {
// GraphQL generation.
graphql: {
// !code: graphql_header
name: 'User',
service: {
sort: { id: 1 },
},
// sql: {
// sqlTable: 'Users',
// uniqueKey: 'id',
// sqlColumn: {
// __authorId__: '__author_id__',
// },
// },
// !end
discard: [
// !code: graphql_discard // !end
],
add: {
// !<DEFAULT> code: graphql_add
// __author__: { type: '__User__!', args: false, relation: { ourTable: '__authorId__', otherTable: 'id' } },
// !end
},
// !code: graphql_more // !end
},
};
// !code: more // !end
let moduleExports = {
schema,
extensions,
// !code: moduleExports // !end
};
// !code: exports // !end
export default moduleExports;
// !code: funcs // !end
// !code: end // !end
/* tslint:disable:quotemark */
// Defines Sequelize model for service `users`. (Can be re-generated.)
import merge from 'lodash.merge';
import Sequelize, { DefineAttributes } from 'sequelize';
// tslint:disable-next-line:no-unused-variable
const DataTypes = (Sequelize as any).DataTypes as Sequelize.DataTypes;
// !code: imports // !end
// !code: init // !end
// Your model may need the following fields:
// email: { type: DataTypes.STRING, allowNull: false, unique: true },
// password: { type: DataTypes.STRING, allowNull: false },
let moduleExports = merge({},
// !<DEFAULT> code: sequelize_model
{
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
email: {
type: DataTypes.TEXT,
allowNull: false
},
firstName: {
type: DataTypes.TEXT,
allowNull: false
},
lastName: {
type: DataTypes.TEXT,
allowNull: false
},
password: {
type: DataTypes.TEXT
},
roleId: {
type: DataTypes.INTEGER,
allowNull: false
}
} as DefineAttributes,
// !end
// !code: moduleExports // !end
);
// !code: exports // !end
export default moduleExports;
// !code: funcs // !end
// !code: end // !end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment