Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
106 lines (96 loc) · 2.15 KB

File metadata and controls

106 lines (96 loc) · 2.15 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
'use strict';
/**
* Module Dependencies
*/
var config = require('./config'),
bunyan = require('bunyan'),
winston = require('winston'),
bunyanWinston = require('bunyan-winston-adapter'),
mysql = require('mysql'),
jwt = require('restify-jwt'),
Mail = require('winston-mail').Mail,
Sentry = require('winston-sentry'),
restifyPlugins = require('restify-plugins');
/**
* Global Dependencies
*/
global.__base = __dirname + '/';
global.config = require('./config.js');
global.restify = require('restify');
/**
* Transports (Logging)
*/
var transports = [
new winston.transports.Console({
level: 'info',
timestamp: function() {
return new Date().toString();
},
json: true,
}),
];
/**
* Sentry Transport (Logging)
*/
if (process.env.SENTRY) {
new winston.transports.Console({ level: 'silly' }), new Sentry({
patchGlobal: true,
dsn: process.env.SENTRY,
});
}
/**
* Logging
*/
global.log = new winston.Logger({
transports: transports,
});
/**
* Initialize Server
*/
global.server = restify.createServer({
name: config.name,
version: config.version,
log: bunyanWinston.createAdapter(log),
});
/**
* Middleware
*/
server.use(restifyPlugins.jsonBodyParser({ mapParams: true }));
server.use(restifyPlugins.acceptParser(server.acceptable));
server.use(restifyPlugins.queryParser({ mapParams: true }));
server.use(restifyPlugins.multipartBodyParser());
server.pre(require('./lib/cors')());
server.use(restifyPlugins.fullResponse());
server.use(
jwt({ secret: config.jwt.secret }).unless({
path: ['/users'],
}),
);
/**
* Initialize MySQL Connection
*/
global.db = mysql.createConnection({
port: config.db.port,
host: config.db.host,
user: config.db.username,
password: config.db.password,
database: config.db.name,
timezone: 'UTC',
});
db.connect();
db.query(`
SET sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
`);
/**
* Boot
*/
server.listen(config.port, function() {
require('./routes');
log.info(
'%s v%s ready to accept connections on port listening on port %s in %s environment',
server.name,
config.version,
config.port,
config.env,
);
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.