-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
61 lines (33 loc) · 1.28 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
50
51
52
53
54
55
56
57
58
59
60
// =================================================================================
// Name : index.js
// Author : Sam (Coding Samrat)
// Description : Root of s3b server
// =================================================================================
import { config as envConfig } from "dotenv";
envConfig()
import express from 'express'
import cookieParser from 'cookie-parser'
import bodyParser from 'body-parser'
import cors from 'cors'
import config from './s3b.config.js'
import ClientFileRouter from './src/routes/client.file.router.js'
import { getVersion } from "./src/libs/version.js";
// Express Server
const app = express();
// Parsers...
app.use(cookieParser());
app.use(bodyParser.json({ limit: config.MAX_FILE_SIZE }))
// CORS Setup
app.use(cors({ credentials: true, origin: true }));
// Static Dir
app.use(express.static('./public'));
app.use(express.static(config.CLOUD_BASE_PATH));
// API Routes
app.use(`${config.API_BASE}/client/file`, ClientFileRouter);
app.listen(config.PORT, async () => {
console.log('')
console.log('s3b-server')
console.log('version -', await getVersion())
console.log("-------------------------------------")
console.log(`\n⚙️ Server is up & running on http://localhost:${config.PORT} ✓`)
})