Skip to content

Commit 0087a41

Browse files
committed
laying out the pieces of the app
1 parent f9538fc commit 0087a41

16 files changed

+9618
-61
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
coverage
4+
5+
configuration.json
6+
development-configuration.json
7+
production-configuration.json

LICENSE

+674
Large diffs are not rendered by default.

api/babel.config.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": ["@babel/preset-env"],
3+
"plugins": ["@babel/plugin-proposal-optional-chaining"],
4+
"ignore": ["node_modules"],
5+
"only": ["src"]
6+
}

api/index.js

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
require("regenerator-runtime");
2+
const restify = require("restify");
3+
const server = restify.createServer();
4+
// const models = require("./src/models");
5+
// const { setupRoutes } = require("./src/routes");
6+
const { loadConfiguration, getLogger } = require("./src/common");
7+
const { setupRoutes } = require("./src/routes");
8+
const corsMiddleware = require("restify-cors-middleware");
9+
const log = getLogger();
10+
11+
(async () => {
12+
let configuration;
13+
try {
14+
configuration = await loadConfiguration();
15+
} catch (error) {
16+
console.error("configuration.json not found - stopping now");
17+
process.exit();
18+
}
19+
// await models.sequelize.sync();
20+
21+
const cors = corsMiddleware({
22+
preflightMaxAge: 5, //Optional
23+
origins: ["*"],
24+
allowHeaders: [
25+
"DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization",
26+
],
27+
exposeHeaders: [
28+
"DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization",
29+
],
30+
});
31+
server.pre(cors.preflight);
32+
server.use(cors.actual);
33+
if (process.env.NODE_ENV === "development") {
34+
server.use((req, res, next) => {
35+
log.debug(`${req.route.method}: ${req.route.path}`);
36+
return next();
37+
});
38+
}
39+
server.use(restify.plugins.dateParser());
40+
server.use(restify.plugins.queryParser());
41+
server.use(restify.plugins.jsonp());
42+
server.use(restify.plugins.gzipResponse());
43+
server.use(
44+
restify.plugins.bodyParser({
45+
maxBodySize: 0,
46+
mapParams: true,
47+
mapFiles: false,
48+
overrideParams: false,
49+
multiples: true,
50+
hash: "sha1",
51+
rejectUnknown: true,
52+
requestBodyOnGet: false,
53+
reviver: undefined,
54+
maxFieldsSize: 2 * 1024 * 1024,
55+
})
56+
);
57+
setupRoutes({ server });
58+
// const configuration = {
59+
// api: {
60+
// port: "8080",
61+
// },
62+
// };
63+
64+
const app = server.listen(configuration.api.port, function () {
65+
console.log("ready on %s", server.url);
66+
});
67+
})();

api/jest.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
verbose: true,
3+
rootDir: "src",
4+
testMatch: ["**/*.spec.js"],
5+
testPathIgnorePatterns: ["node_modules"],
6+
watchPathIgnorePatterns: ["\\**/.*(?<!spec).js"],
7+
};

api/nodemon.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"verbose": false,
3+
"ignore": ["*.spec.js"]
4+
}

0 commit comments

Comments
 (0)