diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..594f6367 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,43 @@ +version: 1.{build} +pull_requests: + do_not_increment_build_number: true +branches: + only: + - master +clone_folder: C:\wafter +init: +- ps: >- + Install-Product node $env:nodejs_version $env:platform +environment: + nodejs_version: 10 +platform: + - x86 + - x64 +install: +- cmd: >- + npm install --global npm@latest + + git clone "https://github.com/vnma0/hestia.git" -b master --single-branch "..\hestia" + + cd ..\hestia + + npm install + + npm run build + + xcopy .\build ..\wafter\public\ /s /e + + cd ..\wafter + + npm install +build_script: +- cmd: >- + npm run pkg + + cd dist\ + + 7z a "wafter-%PLATFORM%-%APPVEYOR_BUILD_VERSION%.zip" wafter.exe +test: off +artifacts: +- path: dist\wafter-%PLATFORM%-%APPVEYOR_BUILD_VERSION%.zip + name: Wafter-%PLATFORM% \ No newline at end of file diff --git a/contest.sample.json b/contest.sample.json index bef050ef..c0bb8d8f 100644 --- a/contest.sample.json +++ b/contest.sample.json @@ -1,7 +1,8 @@ { "name": "Sample Contest", - "startTime": [1970, 0, 1, 0, 0], - "endTime": [1970, 0, 1, 1, 0], + "startTime": "2019-02-27T14:00:00.000Z", + "endTime": "2019-02-27T17:30:00.000Z", "mode": "OI", - "probList": ["LARES", "GCD"] + "probList": ["LARES", "GCD"], + "allowedCodeExt": [".C", ".CPP"] } diff --git a/package.json b/package.json index e6267747..2f5365c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wafter", - "version": "0.1.0", + "version": "1.0.0", "description": "Mirai's Backend", "main": "src/index.js", "bin": "build/index.js", @@ -9,7 +9,7 @@ "start": "node src/index.js", "test": "mocha", "dev": "nodemon src/index.js", - "pkg": "pkg -o dist/wafter ." + "pkg": "npm run build && pkg -o dist/wafter ." }, "pkg": { "scripts": [ diff --git a/src/controller/passportConfig.js b/src/controller/passportConfig.js index 48e423e9..9459c927 100644 --- a/src/controller/passportConfig.js +++ b/src/controller/passportConfig.js @@ -20,11 +20,17 @@ function passportConfig(passport) { }, async (username, password, done) => { try { - const dbUser = await readUser(username); + const dbUser = await readUser(username).catch(() => null); + if (!dbUser) + return done(null, false, { message: "Cannot read user" }); + const passHash = await readUserPassHash(dbUser._id); const isMatch = await bcrypt.compare(password, passHash); - if (isMatch) return done(null, dbUser); - else done(null, false); + if (!isMatch) + return done(null, false, { message: "Password mismatch" }); + + if (dbUser && isMatch) return done(null, dbUser); + else return done(null, false, { message: "Unknown error" }); } catch (err) { done(err); } diff --git a/src/index.js b/src/index.js index 3bc47d45..1aa96105 100644 --- a/src/index.js +++ b/src/index.js @@ -27,6 +27,8 @@ async function mainPrompt() { */ async function main() { let res = {}; + Console.log("MIRAI Wafter 1.0.0"); + Console.log("Copyright (c) 2018 Vườn ươm A0. MIT License."); try { while (res.main !== "Exit") { res = await mainPrompt(); diff --git a/src/server.js b/src/server.js index fd21e056..be2030e8 100644 --- a/src/server.js +++ b/src/server.js @@ -74,3 +74,9 @@ let serv = app.listen(PORT, () => { `Wafter is serving at http://${ip.address()}:${serv.address().port}` ); }); +process.on("exit", () => { + serv.close(() => { + Console.log("Closing server"); + process.exit(0); + }); +}); diff --git a/src/util/config/readCtConfig.js b/src/util/config/readCtConfig.js index 1d58facf..05b82ee7 100644 --- a/src/util/config/readCtConfig.js +++ b/src/util/config/readCtConfig.js @@ -4,16 +4,14 @@ const score = require("../score"); const readConfig = require("../readConfig"); /** - * Parse Object into Date object - * @param {Object} timeData + * Parse ISO 8601 into Date object + * @param {String} timeData ISO 8601 String */ function parseTime(timeData) { - try { - if (Array.isArray(timeData)) return new Date(...timeData); - else return new Date(timeData); - } catch (err) { + // Must be a number + if (new Date(timeData).toJSON() !== timeData) throw new Error("Invalid Time"); - } + else return new Date(timeData); } /**