Commit 756a4653 authored by chinguyen's avatar chinguyen

Merge branch 'develop' into 'jwt'

# Conflicts:
#   src/config.json
parents 63e28623 c7ec33c7
{
"version": "0.2.0",
"configurations": [
{
"args": [
"task"
],
"name": "Gulp task",
"program": "${workspaceFolder}/node_modules/gulp/bin/gulp.js",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
"name": "Debug Typescript",
"type": "node",
......
......@@ -17,7 +17,7 @@
"scripts": {
"build": "gulp build",
"doc": "gulp generate:doc",
"start": "cross-env NODE_ENV=development gulp watch",
"start": "cross-env NODE_ENV=development gulp watch ",
"start:prod": "cross-env NODE_ENV=production gulp watch",
"run:test": "cross-env NODE_ENV=test gulp test",
"tslint": "gulp tslint",
......@@ -62,7 +62,7 @@
"lint-staged": "10.0.7",
"remap-istanbul": "0.13.0",
"rimraf": "3.0.2",
"sequelize-cli": "5.5.1",
"sequelize-cli": "^5.5.1",
"tslint": "6.0.0",
"typedoc": "0.16.10",
"typescript": "3.8.2",
......
{
"development": {
"username": "postgres",
"password": "meu@sds12@!#gh",
"password": "chinguyen@123",
"database": "node_sequelize",
"host": "27.74.255.96",
"port": 5430,
......
import * as uuid from 'uuid'
import { Students } from './../sqlz/models/students'
import { where, Op } from 'sequelize/types';
import { Request, Response } from 'express'
export function create(students: any): Promise<any> {
return Students.create({
......@@ -18,14 +19,17 @@ export function findAll(): Promise<any> {
}
export function findStudentPagination(page: any, pagesize: any): Promise<any>{
return Students.findAll({
export function findStudentPagination (page:any, pagesize:any): Promise<any>{
return Students.findAndCountAll({
offset: (page - 1 ) * pagesize,
limit: pagesize
//offset: 1,
//limit: 2
})
}
}
export function deleteUser(code: any): Promise<any> {
return Students.destroy({
......
......@@ -2,14 +2,14 @@ import { Request, Response } from 'express'
import { StudentDao } from '../../dao/_index'
export function getAllUsers(req: Request, res: Response) {
export function getAllUsers(req: Request, res: Response) {
return StudentDao
.findAll()
.then(students => res.status(200).send(students))
.catch(error => res.boom.badRequest(error))
}
export function getUserBasePagination(req: Request, res: Response){
export function getUserBasePagination(req: Request, res: Response) {
return StudentDao.findStudentPagination(req.query.page, req.query.pagesize)
.then(students => res.status(200).send(students))
.then(students => res.status(200).send(students.rows))
}
......@@ -2,8 +2,8 @@ import { Express } from 'express'
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.get('/api/students/all', StudentsController.StudentsGet.getAllUsers)
app.get('/api/students/paging*', 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)
......
{
"development": {
"username": "postgres",
"password": "chinguyen",
"password": "chinguyen@123",
"database": "node_sequelize",
"host": "127.0.0.1",
"port": 5432,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment