From 9090d4e2ca1319665331a01bae405f92bbda4838 Mon Sep 17 00:00:00 2001 From: Pacharapol Withayasakpunt Date: Fri, 15 Oct 2021 12:44:04 +0700 Subject: [PATCH] update login api --- package.json | 2 +- src/api/index.ts | 6 +++--- src/tsconfig.json | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 src/tsconfig.json diff --git a/package.json b/package.json index 75bf10e..fcb918b 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "license": "MIT", "scripts": { "ts": "ts-node", - "build": "rm -r lib && tsc --rootDir src --outDir lib" + "build": "rm -r lib && tsc -p src/tsconfig.json" }, "dependencies": { "@databases/pg": "^5.1.1", diff --git a/src/api/index.ts b/src/api/index.ts index d544eba..8518ca7 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -117,10 +117,10 @@ const apiRouter: FastifyPluginAsync = async (f) => { const userId = userData.data.id await db.query(sql` - INSERT INTO "user" ("id", "level") - VALUES (${userId}, ${userData.data.level}) + INSERT INTO "user" ("id", "identifier", "level.max") + VALUES (${userId}, ${userData.data.username}, ${userData.data.level}) ON CONFLICT ("id") DO UPDATE SET - "level" = EXCLUDED."level" + "level.max" = EXCLUDED."level.max" `) req.session['userId'] = userId diff --git a/src/tsconfig.json b/src/tsconfig.json new file mode 100644 index 0000000..42905d2 --- /dev/null +++ b/src/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "../lib", + "sourceMap": true + } +} \ No newline at end of file