Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
chinguyen_nodejs_managestudents
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chinguyen
chinguyen_nodejs_managestudents
Commits
76ee8ef5
Commit
76ee8ef5
authored
Feb 05, 2021
by
chinguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
4f6cd08d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
0 deletions
+16
-0
students.ts
src/dao/students.ts
+9
-0
students.get.ts
src/endpoints/students/students.get.ts
+5
-0
students.ts
src/routes/students.ts
+2
-0
No files found.
src/dao/students.ts
View file @
76ee8ef5
...
...
@@ -18,6 +18,15 @@ export function findAll(): Promise<any> {
}
export
function
findStudentPagination
(
page
:
any
,
pagesize
:
any
):
Promise
<
any
>
{
return
Students
.
findAll
({
offset
:
(
page
-
1
)
*
pagesize
,
limit
:
pagesize
})
}
export
function
deleteUser
(
code
:
any
):
Promise
<
any
>
{
return
Students
.
destroy
({
where
:{
code
}
...
...
src/endpoints/students/students.get.ts
View file @
76ee8ef5
...
...
@@ -7,4 +7,9 @@ export function getAllUsers(req: Request, res: Response) {
.
findAll
()
.
then
(
students
=>
res
.
status
(
200
).
send
(
students
))
.
catch
(
error
=>
res
.
boom
.
badRequest
(
error
))
}
export
function
getUserBasePagination
(
req
:
Request
,
res
:
Response
){
return
StudentDao
.
findStudentPagination
(
req
.
query
.
page
,
req
.
query
.
pagesize
)
.
then
(
students
=>
res
.
status
(
200
).
send
(
students
))
}
\ No newline at end of file
src/routes/students.ts
View file @
76ee8ef5
...
...
@@ -3,7 +3,9 @@ import { StudentsController } from '../endpoints/_index'
export
function
routes
(
app
:
Express
)
{
app
.
get
(
'/api/getStudents'
,
StudentsController
.
StudentsGet
.
getAllUsers
)
app
.
get
(
'/api/getStudents?page&pagesize'
,
StudentsController
.
StudentsGet
.
getUserBasePagination
)
app
.
post
(
'/api/addStudent'
,
StudentsController
.
StudentsPost
.
Add
)
app
.
delete
(
'/api/deleteStudent/:code'
,
StudentsController
.
StudentsDelete
.
deleteUser
)
app
.
put
(
'/api/updateStudent/:code'
,
StudentsController
.
StudentsPut
.
updateUser
)
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment