master
12 months ago
3 changed files with 66 additions and 0 deletions
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
/** |
||||
* Main program of Hero Union of filesite.io |
||||
**/ |
||||
|
||||
import express from 'express'; |
||||
import bodyParser from 'body-parser'; |
||||
|
||||
const app = express(); |
||||
|
||||
//Express behind proxies
|
||||
app.set('trust proxy', true); |
||||
app.disable('x-powered-by'); |
||||
|
||||
//Serving static files
|
||||
app.use(express.static('public')); |
||||
|
||||
// parse application/x-www-form-urlencoded
|
||||
app.use(bodyParser.urlencoded({ extended: false })) |
||||
// parse application/json
|
||||
app.use(bodyParser.json()) |
||||
|
||||
//TODO: add api handler
|
||||
|
||||
|
||||
app.get('/', (req, res) => { |
||||
return res.send('Welcome to Hero Union of filesite.io'); |
||||
}); |
||||
|
||||
//error handler
|
||||
app.use((err, req, res, next) => { |
||||
if (res.headersSent) { |
||||
return next(err); |
||||
} |
||||
|
||||
console.error('Request error in tg bot: %s', err.stack); |
||||
|
||||
var statusCode = 500; |
||||
if (typeof(err.statusCode) != 'undefined' && err.statusCode) { |
||||
statusCode = err.statusCode; |
||||
} |
||||
return res.status(statusCode).send(err.message); |
||||
}) |
||||
|
||||
// Listen to the App Engine-specified port, or 8080 otherwise
|
||||
const PORT = process.env.PORT || 8080; |
||||
app.listen(PORT, async () => { |
||||
console.log('Server listening on port %s...', PORT); |
||||
}); |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
{ |
||||
"name": "Hero Union", |
||||
"version": "0.1", |
||||
"author": "filesite.io", |
||||
"type": "module", |
||||
"dependencies": { |
||||
"axios": "^1.3.3", |
||||
"body-parser": "^1.20.1", |
||||
"express": "^4.18.2", |
||||
"md5": "^2.3.0", |
||||
"node-cron": "^3.0.2" |
||||
}, |
||||
"scripts": { |
||||
"start": "node index.mjs" |
||||
} |
||||
} |
Loading…
Reference in new issue