-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (36 loc) · 1.11 KB
/
index.js
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
const monogoUri = process.env.MONGODB_URI;
const fastify = require("fastify")({
logger: {
level: "trace",
},
});
require("dotenv").config();
const port = process.env.PORT || 1234;
fastify.register(require("fastify-formbody"));
fastify.register(require("fastify-mongoose-odm"), monogoUri, err => {
if (err) throw err;
});
fastify.register(require("./fastify-redis"), {}, err => {
if (err) throw err;
});
fastify.get("/", async () => {
return "Hello World!";
});
fastify.register(require("./model.js"));
fastify.register(require("./slack.js"));
fastify.register(require("./routes/auth.js"));
fastify.register(require("./routes/commands.js"));
String.prototype.truncate = function(maxCharacters) {
return this.length > maxCharacters ? this.substring(0, maxCharacters) + "…" : this;
};
const start = async () => {
try {
await fastify.listen(port, "0.0.0.0");
fastify.log.info(fastify.printRoutes());
fastify.log.info(`Listening on ${fastify.server.address().port}`);
} catch (err) {
fastify.log.error(err);
process.exit(1);
}
};
start();