Skip to content

Commit bab01b6

Browse files
committed
feat(api): schools controller
Fixes #49
1 parent f2194a2 commit bab01b6

24 files changed

+619
-37
lines changed

.github/workflows/api_pr_coverage_report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616

1717
- name: Install Dependencies
1818
run: npm ci
19+
working-directory: modules/
1920

2021
- name: Run Jest Tests with Coverage
2122
run: npm run test

modules/libs/protocol/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export * from './routes'
55
export * from './roles'
66
export * from './userRoles'
77
export * from './users'
8+
export * from './schools'

modules/libs/protocol/routes.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,12 @@ export const Routes = (baseUrl: string = '') => ({
3232
delete: (roleId: string) => `${baseUrl}/edu/users/${userId}/roles/${roleId}`,
3333
}
3434
}),
35+
schools: {
36+
find: () => `${baseUrl}/edu/schools`,
37+
get: (id: string) => `${baseUrl}/edu/schools/${id}`,
38+
create: () => `${baseUrl}/edu/schools`,
39+
update: (id: string) => `${baseUrl}/edu/schools/${id}`,
40+
delete: (id: string) => `${baseUrl}/edu/schools/${id}`,
41+
}
3542
}
3643
})

modules/libs/protocol/schools.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import * as crud from './crud'
2+
3+
/* -------------------------------------------------------------------------- */
4+
/* Models */
5+
/* -------------------------------------------------------------------------- */
6+
7+
export type SchoolDetails = {
8+
id: string;
9+
name: string;
10+
}
11+
12+
export type SchoolSummary = Pick<SchoolDetails, 'id' | 'name'>;
13+
14+
/* -------------------------------------------------------------------------- */
15+
/* Create */
16+
/* -------------------------------------------------------------------------- */
17+
18+
export type CreateSchoolRequest = crud.CreateItemRequest<Omit<SchoolDetails, 'id'>>;
19+
export type CreateSchoolResponse = crud.CreateItemResponse<SchoolDetails['id']>;
20+
21+
/* -------------------------------------------------------------------------- */
22+
/* Read */
23+
/* -------------------------------------------------------------------------- */
24+
25+
export type GetSchoolsResponse =
26+
crud.GetItemsListResponse<SchoolSummary>;
27+
28+
export type GetSchoolResponse =
29+
crud.GetItemResponse<SchoolDetails>;
30+
31+
/* -------------------------------------------------------------------------- */
32+
/* Update */
33+
/* -------------------------------------------------------------------------- */
34+
35+
export type UpdateSchoolRequest =
36+
crud.UpdateItemRequest<Omit<SchoolDetails, 'id'>>;
37+
38+
export type UpdateSchoolResponse =
39+
crud.UpdateItemResponse<SchoolDetails>;
40+
41+
/* -------------------------------------------------------------------------- */
42+
/* Delete */
43+
/* -------------------------------------------------------------------------- */
44+
45+
export type DeleteSchoolResponse =
46+
crud.DeleteItemResponse;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
moduleFileExtensions: ['js', 'json', 'ts'],
3+
rootDir: 'src',
4+
testRegex: '.*\\.spec\\.ts$',
5+
transform: {
6+
'^.+\\.(t|j)s$': 'ts-jest',
7+
},
8+
collectCoverageFrom: ['**/*.(t|j)s'],
9+
testTimeout: 20000,
10+
coverageDirectory: '../coverage',
11+
testEnvironment: 'node',
12+
moduleNameMapper: {
13+
'^@vidya/api/(.*)$': '<rootDir>/$1',
14+
'^@vidya/protocol$': '<rootDir>/../../../libs/protocol',
15+
'^@vidya/entities$': '<rootDir>/../../../libs/entities',
16+
'^@vidya/domain$': '<rootDir>/../../../libs/domain',
17+
},
18+
};

modules/services/api/package.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,29 +66,5 @@
6666
"ts-node": "^10.9.2",
6767
"tsconfig-paths": "^4.2.0",
6868
"typescript": "^5.1.3"
69-
},
70-
"jest": {
71-
"moduleFileExtensions": [
72-
"js",
73-
"json",
74-
"ts"
75-
],
76-
"rootDir": "src",
77-
"testRegex": ".*\\.spec\\.ts$",
78-
"transform": {
79-
"^.+\\.(t|j)s$": "ts-jest"
80-
},
81-
"collectCoverageFrom": [
82-
"**/*.(t|j)s"
83-
],
84-
"testTimeout": 20000,
85-
"coverageDirectory": "../coverage",
86-
"testEnvironment": "node",
87-
"moduleNameMapper": {
88-
"^@vidya/api/(.*)$": "<rootDir>/$1",
89-
"^@vidya/protocol$": "<rootDir>/../../../libs/protocol",
90-
"^@vidya/entities$": "<rootDir>/../../../libs/entities",
91-
"^@vidya/domain$": "<rootDir>/../../../libs/domain"
92-
}
9369
}
9470
}

modules/services/api/src/auth/controllers/otp.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { OtpService } from '@vidya/api/auth/services';
1818
import { Routes } from '@vidya/protocol';
1919

2020
@Controller()
21-
@ApiTags('Authentication :: One-Time Password')
21+
@ApiTags('🎟️ Authentication :: One-Time Password')
2222
export class OtpController {
2323
constructor(private readonly otpService: OtpService) {}
2424

modules/services/api/src/auth/controllers/tokens.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
import { Routes } from '@vidya/protocol';
2222

2323
@Controller()
24-
@ApiTags('Authentication')
24+
@ApiTags('🔐 Authentication')
2525
export class TokensController {
2626
constructor(
2727
private readonly revokedTokensService: RevokedTokensService,

modules/services/api/src/auth/controllers/user-authentication.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { AuthConfig } from '@vidya/api/configs';
2929
import { JwtToken, OtpType, Routes } from '@vidya/protocol';
3030

3131
@Controller()
32-
@ApiTags('Authentication')
32+
@ApiTags('🔐 Authentication')
3333
export class UserAuthenticationController {
3434
constructor(
3535
@Inject(AuthConfig.KEY)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './roles/roles.controller';
2+
export * from './schools/schools.controller';
23
export * from './users/userRoles.controller';
34
export * from './users/users.controller';

0 commit comments

Comments
 (0)