123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- const express = require('express');
- const app = express();
- const PORT = 2345;
- app.use(express.json());
- class Log {
- static debug(message, additionalInfo = '') {
- this.log('D', message, additionalInfo, '\x1b[34m');
- }
- static info(message, additionalInfo = '') {
- this.log('I', message, additionalInfo, '\x1b[32m');
- }
- static success(message, additionalInfo = '') {
- this.log('S', message, additionalInfo, '\x1b[36m');
- }
- static warning(message, additionalInfo = '') {
- this.log('W', message, additionalInfo, '\x1b[33m');
- }
- static error(message, additionalInfo = '') {
- this.log('E', message, additionalInfo, '\x1b[31m');
- }
- static log(level, message, additionalInfo, color) {
- const timestamp = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '');
- const logMessage = `${timestamp} [${level}] ${additionalInfo} ${message}`;
- console.log(`${color}${logMessage}\x1b[0m`);
- }
- }
- // 访问根路径返回
- app.get("/", (res, req) => {
-
- });
- // 根据取件码获取文件
- // 返回文件的二进制流或者返回文件下载的直接链接
- app.post("/fetch", (res, req) => {
-
- });
- // 上传文件获取取件码
- // 返回内容包括:取件码 文件名 文件大小
- app.post("/upload", (res, req) => {
-
- });
- // 用于相应直接链接的下载请求
- app.get("/download", (res, req) => {
- });
- // 获取统计信息
- app.get("/statistic", (res, req) => {
- });
- app.listen(PORT, () => {
- Log.info("Server running on port: " + PORT + ";")
- });
|