File tree Expand file tree Collapse file tree 11 files changed +369
-27
lines changed Expand file tree Collapse file tree 11 files changed +369
-27
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ node_modules/
2
2
package-lock.json
3
3
dist /
4
4
type /* .d.ts
5
- .env
5
+ .env *
6
6
.data /
7
7
.vscode /settings.json
Original file line number Diff line number Diff line change 46
46
47
47
| Name | Usage |
48
48
| :------------: | :--------------------------: |
49
- | ` APP_SECRET ` | encrypt Password & Token |
49
+ | ` JWT_SECRET ` | encrypt Password & Token |
50
50
| ` DATABASE_URL ` | PostgreSQL connection string |
51
51
52
52
## Development
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ services:
9
9
postgres :
10
10
image : postgres
11
11
environment :
12
- - POSTGRES_PASSWORD=${APP_SECRET }
12
+ - POSTGRES_PASSWORD=${JWT_SECRET }
13
13
volumes :
14
14
- database-data:/var/lib/postgresql/data/
15
15
networks :
@@ -21,7 +21,7 @@ services:
21
21
image : kaiyuanshe/openhackathon-service
22
22
environment :
23
23
- NODE_ENV=production
24
- - DATABASE_URL=postgres://postgres:${APP_SECRET }@postgres:5432/postgres
24
+ - DATABASE_URL=postgres://postgres:${JWT_SECRET }@postgres:5432/postgres
25
25
- PORT=8080
26
26
networks :
27
27
- kaiyuanshe
Original file line number Diff line number Diff line change 20
20
"dependencies" : {
21
21
"@koa/cors" : " ^5.0.0" ,
22
22
"@koa/multer" : " ^3.0.2" ,
23
- "@koa/router" : " ^12 .0.1 " ,
23
+ "@koa/router" : " ^13 .0.0 " ,
24
24
"@octokit/openapi-types" : " ^22.2.0" ,
25
25
"class-transformer" : " ^0.5.1" ,
26
26
"class-validator" : " ^0.14.1" ,
54
54
"@typescript-eslint/parser" : " ^8.1.0" ,
55
55
"eslint" : " ^8.57.0" ,
56
56
"eslint-plugin-simple-import-sort" : " ^12.1.1" ,
57
+ "get-git-folder" : " ^0.1.2" ,
57
58
"husky" : " ^9.1.4" ,
58
59
"lint-staged" : " ^15.2.9" ,
59
60
"prettier" : " ^3.3.3" ,
72
73
},
73
74
"scripts" : {
74
75
"prepare" : " husky || true" ,
76
+ "install" : " get-git-folder https://github.com/kaiyuanshe/service-configuration main OpenHackathon-Web || true" ,
75
77
"dev" : " ts-node-dev source/" ,
76
78
"test" : " lint-staged" ,
77
79
"build" : " rm -rf dist/ type/*.d.ts && tsc && mv dist/model/*.d.ts type/" ,
Original file line number Diff line number Diff line change @@ -16,12 +16,12 @@ export class OauthController {
16
16
const response = await fetch ( 'https://api.github.com/user' , {
17
17
headers : { Authorization : `Bearer ${ accessToken } ` }
18
18
} ) ;
19
- const { email, name , avatar_url } =
19
+ const { email, login , avatar_url } =
20
20
( await response . json ( ) ) as GitHubUser ;
21
21
const user =
22
22
( await store . findOneBy ( { email } ) ) ||
23
23
( await UserController . signUp ( { email, password : accessToken } ) ) ;
24
- const newProfile = { name, avatar_url } ,
24
+ const newProfile = { name : login , avatar : avatar_url } ,
25
25
oldPofile = { name : user . name , avatar : user . avatar } ;
26
26
27
27
if ( ! isDeepStrictEqual ( oldPofile , newProfile ) ) {
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ import {
27
27
UserFilter ,
28
28
UserListChunk
29
29
} from '../model' ;
30
- import { APP_SECRET , searchConditionOf } from '../utility' ;
30
+ import { JWT_SECRET , searchConditionOf } from '../utility' ;
31
31
import { ActivityLogController } from './ActivityLog' ;
32
32
33
33
const store = dataSource . getRepository ( User ) ;
@@ -36,12 +36,12 @@ const store = dataSource.getRepository(User);
36
36
export class UserController {
37
37
static encrypt = ( raw : string ) =>
38
38
createHash ( 'sha1' )
39
- . update ( APP_SECRET + raw )
39
+ . update ( JWT_SECRET + raw )
40
40
. digest ( 'hex' ) ;
41
41
42
42
static sign = ( user : User ) : User => ( {
43
43
...user ,
44
- token : sign ( { ...user } , APP_SECRET )
44
+ token : sign ( { ...user } , JWT_SECRET )
45
45
} ) ;
46
46
47
47
static async signUp ( data : SignInData ) {
Original file line number Diff line number Diff line change @@ -14,13 +14,13 @@ import {
14
14
UserController
15
15
} from './controller' ;
16
16
import { dataSource } from './model' ;
17
- import { APP_SECRET , isProduct , PORT } from './utility' ;
17
+ import { JWT_SECRET , isProduct , PORT } from './utility' ;
18
18
19
19
const HOST = `localhost:${ PORT } ` ,
20
20
app = new Koa ( )
21
21
. use ( KoaLogger ( ) )
22
22
. use ( swagger ( { exposeSpec : true } ) )
23
- . use ( jwt ( { secret : APP_SECRET , passthrough : true } ) ) ;
23
+ . use ( jwt ( { secret : JWT_SECRET , passthrough : true } ) ) ;
24
24
25
25
if ( ! isProduct ) app . use ( mocker ( ) ) ;
26
26
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ export class Hackathon extends UserBase {
86
86
@Min ( 0 )
87
87
@VirtualColumn ( {
88
88
query : alias =>
89
- `SELECT COUNT(*) FROM "Enrollment " WHERE hackathonId = ${ alias } .id`
89
+ `SELECT COUNT(*) FROM "enrollment " WHERE hackathonId = ${ alias } .id`
90
90
} )
91
91
enrollment : number ;
92
92
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionO
5
5
import { DATABASE_URL , isProduct } from '../utility' ;
6
6
import { User } from './User' ;
7
7
import { PlatformAdmin } from './PlatformAdmin' ;
8
- import { ActivityLog } from './ActivityLog' ;
8
+ import { ActivityLog , UserRank } from './ActivityLog' ;
9
9
import { Hackathon } from './Hackathon' ;
10
10
import { Staff } from './Staff' ;
11
11
import { Organizer } from './Organizer' ;
@@ -35,6 +35,7 @@ const commonOptions: Pick<
35
35
User ,
36
36
PlatformAdmin ,
37
37
ActivityLog ,
38
+ UserRank ,
38
39
Hackathon ,
39
40
Staff ,
40
41
Organizer ,
You can’t perform that action at this time.
0 commit comments