Skip to content

Commit

Permalink
Merge pull request #43 from vnma0/ver
Browse files Browse the repository at this point in the history
Finalize string
  • Loading branch information
enbugging authored Feb 28, 2019
2 parents 571f95b + c37d705 commit 78befa5
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 15 deletions.
43 changes: 43 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -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%
7 changes: 4 additions & 3 deletions contest.sample.json
Original file line number Diff line number Diff line change
@@ -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"]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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": [
Expand Down
12 changes: 9 additions & 3 deletions src/controller/passportConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
12 changes: 5 additions & 7 deletions src/util/config/readCtConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 78befa5

Please sign in to comment.