This repository has been archived by the owner on Feb 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16179d5
commit 18ea9e4
Showing
75 changed files
with
7,028 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
PORT=33000 | ||
TZ=UTC | ||
ENV=production | ||
SERVICE_USER= | ||
SERVICE_GROUP= | ||
|
||
DB_PROD_HOST= | ||
DB_PROD_USER= | ||
DB_PROD_PASS= | ||
DB_PROD_DB= | ||
|
||
DB_TEST_HOST= | ||
DB_TEST_USER= | ||
DB_TEST_PASS= | ||
DB_TEST_DB= | ||
|
||
|
||
DB_DEV_HOST= | ||
DB_DEV_USER= | ||
DB_DEV_PASS= | ||
DB_DEV_DB= | ||
|
||
SENTRY_DSN=https://{PUBLIC_KEY}@sentry.io/{PROJECT_ID} | ||
|
||
APIDOCS_DOMAIN=apidocs.example.com | ||
|
||
FREE_SMS_API_USER= | ||
FREE_SMS_API_PASS= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
public | ||
apidocs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"strict": true, | ||
"curly": true, | ||
"quotmark": "simple", | ||
"esversion": 6, | ||
"browser": false, | ||
"mocha": true, | ||
"node": true, | ||
"noempty": true, | ||
"debug": false, | ||
"globals": { | ||
"logger": false, | ||
"app": false, | ||
"cluster": false, | ||
"sequelize": false, | ||
"Sentry": false, | ||
"queue": false, | ||
"smsQueue": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
public | ||
apidocs | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
'config': path.resolve('config', 'db.js'), | ||
'models-path': path.resolve('db', 'models'), | ||
'seeders-path': path.resolve('db', 'seeders'), | ||
'migrations-path': path.resolve('db', 'migrations') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# stats | ||
Wdes stats | ||
# wdes-stats | ||
WdesStats server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require('dotenv').config({ path: __dirname + '/../.env' }); | ||
|
||
const pool = { | ||
max: 5, | ||
min: 0, | ||
acquire: 30000, | ||
idle: 10000, | ||
}; | ||
|
||
const define = { | ||
underscored: false, | ||
freezeTableName: false, | ||
charset: 'utf8', | ||
dialectOptions: { | ||
collate: 'utf8_general_ci', | ||
}, | ||
timestamps: true, | ||
}; | ||
|
||
module.exports = { | ||
development: { | ||
username: process.env.DB_DEV_USER, | ||
password: process.env.DB_DEV_PASS, | ||
database: process.env.DB_DEV_DB, | ||
host: process.env.DB_DEV_HOST, | ||
seederStorage: 'json', | ||
dialect: 'mysql', | ||
migrationStorageTableName: 'migrations', | ||
operatorsAliases: false, | ||
pool: pool, | ||
define: define, | ||
}, | ||
test: { | ||
username: process.env.DB_TEST_USER, | ||
password: process.env.DB_TEST_PASS, | ||
database: process.env.DB_TEST_DB, | ||
host: process.env.DB_TEST_HOST, | ||
seederStorage: 'json', | ||
dialect: 'mysql', | ||
migrationStorageTableName: 'migrations', | ||
operatorsAliases: false, | ||
pool: pool, | ||
define: define, | ||
}, | ||
production: { | ||
username: process.env.DB_PROD_USER, | ||
password: process.env.DB_PROD_PASS, | ||
database: process.env.DB_PROD_DB, | ||
host: process.env.DB_PROD_HOST, | ||
seederStorage: 'json', | ||
dialect: 'mysql', | ||
migrationStorageTableName: 'migrations', | ||
operatorsAliases: false, | ||
pool: pool, | ||
define: define, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
return queryInterface.createTable('Api__Scopes', { | ||
name: { | ||
primaryKey: true, | ||
type: Sequelize.STRING, | ||
comment: 'Nom du scope', | ||
}, | ||
description: { | ||
type: Sequelize.STRING, | ||
comment: 'Description du scope', | ||
}, | ||
}); | ||
}, | ||
down: queryInterface => { | ||
return queryInterface.dropTable('Api__Scopes'); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
return queryInterface.createTable('Api__TokenAliases', { | ||
token: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.STRING, | ||
comment: 'Token', | ||
}, | ||
alias: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.STRING, | ||
comment: 'Alias du groupe de scopes', | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
comment: 'Creation date', | ||
}, | ||
updatedAt: { | ||
allowNull: true, | ||
type: Sequelize.DATE, | ||
comment: 'Update date', | ||
}, | ||
}); | ||
}, | ||
down: queryInterface => { | ||
return queryInterface.dropTable('Api__TokenAliases'); | ||
}, | ||
}; |
30 changes: 30 additions & 0 deletions
30
db/migrations/20181220110530-create-api-token-expirations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
return queryInterface.createTable('Api__TokenExpirations', { | ||
token: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.STRING, | ||
comment: 'Token', | ||
}, | ||
expires: { | ||
type: Sequelize.DATE, | ||
comment: 'Expiration du token', | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
comment: 'Creation date', | ||
}, | ||
updatedAt: { | ||
allowNull: true, | ||
type: Sequelize.DATE, | ||
comment: 'Update date', | ||
}, | ||
}); | ||
}, | ||
down: queryInterface => { | ||
return queryInterface.dropTable('Api__TokenExpirations'); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
return queryInterface.createTable('Api__TokenScopes', { | ||
name: { | ||
type: Sequelize.STRING, | ||
primaryKey: true, | ||
allowNull: false, | ||
comment: 'Nom du scope', | ||
references: { model: 'Api__Scopes', key: 'name' }, | ||
}, | ||
groupName: { | ||
primaryKey: true, | ||
allowNull: false, | ||
type: Sequelize.STRING, | ||
comment: 'Nom du groupe de scopes', | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
comment: 'Creation date', | ||
}, | ||
updatedAt: { | ||
allowNull: true, | ||
type: Sequelize.DATE, | ||
comment: 'Update date', | ||
}, | ||
}); | ||
}, | ||
down: (queryInterface, Sequelize) => { | ||
return queryInterface.dropTable('Api__TokenScopes'); | ||
}, | ||
}; |
18 changes: 18 additions & 0 deletions
18
db/migrations/20190121093152-create-api-function-tokenExists.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
// SET GLOBAL log_bin_trust_function_creators = 1; | ||
return queryInterface.sequelize.query( | ||
`CREATE FUNCTION \`tokenExists\`(\`token\` VARCHAR(128) CHARSET utf8mb4) | ||
RETURNS tinyint(1) unsigned READS SQL DATA | ||
BEGIN | ||
RETURN ( SELECT Count(*) FROM Api__TokenAliases WHERE Api__TokenAliases.token = token ) > 0; | ||
END` | ||
); | ||
}, | ||
|
||
down: (queryInterface, Sequelize) => { | ||
return queryInterface.sequelize.query('DROP FUNCTION tokenExists'); | ||
}, | ||
}; |
18 changes: 18 additions & 0 deletions
18
db/migrations/20190121093528-create-api-function-hasPermission.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
// SET GLOBAL log_bin_trust_function_creators = 1; | ||
return queryInterface.sequelize.query( | ||
`CREATE FUNCTION \`hasPermission\`(\`token\` VARCHAR(128) CHARSET utf8mb4, \`scope\` VARCHAR(50)CHARSET utf8mb4) | ||
RETURNS tinyint(1) READS SQL DATA | ||
BEGIN | ||
RETURN ( SELECT COUNT(*) > 0 FROM Api__TokenAliases,Api__TokenScopes WHERE Api__TokenAliases.alias = Api__TokenScopes.groupName AND Api__TokenAliases.token = token AND Api__TokenScopes.name = scope); | ||
END` | ||
); | ||
}, | ||
|
||
down: (queryInterface, Sequelize) => { | ||
return queryInterface.sequelize.query('DROP FUNCTION hasPermission'); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
const Api__TokenAliases = queryInterface.sequelize.import( | ||
__dirname + '/../models/api__tokenaliases' | ||
); | ||
return Api__TokenAliases.create({ | ||
token: 'PuBlIcWGESsra7tbxYsDQ8PQOhMT0KeN', | ||
alias: 'public', | ||
}); | ||
}, | ||
|
||
down: (queryInterface, Sequelize) => { | ||
const Api__TokenAliases = queryInterface.sequelize.import( | ||
__dirname + '/../models/api__tokenaliases' | ||
); | ||
return Api__TokenAliases.findOne({ | ||
where: { | ||
token: 'PuBlIcWGESsra7tbxYsDQ8PQOhMT0KeN', | ||
alias: 'public', | ||
}, | ||
}).then(model => { | ||
model.destroy(); | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
const Api__Scopes = queryInterface.sequelize.import( | ||
__dirname + '/../models/api__scopes' | ||
); | ||
return Api__Scopes.create({ | ||
name: 'api.index', | ||
description: 'Api description and status', | ||
}); | ||
}, | ||
|
||
down: (queryInterface, Sequelize) => { | ||
const Api__Scopes = queryInterface.sequelize.import( | ||
__dirname + '/../models/api__scopes' | ||
); | ||
return Api__Scopes.findByPk('api.index').then(model => { | ||
model.destroy(); | ||
}); | ||
}, | ||
}; |
27 changes: 27 additions & 0 deletions
27
db/migrations/20190121122225-data-public-api-token-scopes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
const Api__TokenScopes = queryInterface.sequelize.import( | ||
__dirname + '/../models/api__tokenscopes' | ||
); | ||
return Api__TokenScopes.create({ | ||
name: 'api.index', | ||
groupName: 'public', | ||
}); | ||
}, | ||
|
||
down: (queryInterface, Sequelize) => { | ||
const Api__TokenScopes = queryInterface.sequelize.import( | ||
__dirname + '/../models/api__tokenscopes' | ||
); | ||
return Api__TokenScopes.findOne({ | ||
where: { | ||
name: 'api.index', | ||
groupName: 'public', | ||
}, | ||
}).then(model => { | ||
model.destroy(); | ||
}); | ||
}, | ||
}; |
Oops, something went wrong.