Skip to content

Instantly share code, notes, and snippets.

{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": true,
"outDir": "./build",
"rootDir": "./src",
/* Strict Type-Checking Options */
"strict": true,
/* Module Resolution Options */
Create table student(id varchar(10), name varchar(50), email varchar(100), age int(5));
import { DBManager } from "./DBManager";
import { IStudent } from "../types/types";
export class StudentDA extends DBManager {
public async GetStudents() {
const query = "select * from student"
try {
const data = await this.ReadData(query);
return data;
import express from 'express';
import dotenv from 'dotenv';
import { StudentDA } from './DA/index';
import { StudentService } from './service/index';
import { StudentRouter } from "./routes/index";
dotenv.config();
import { StudentService } from '../service';
import { Router, Response, Request } from 'express';
export const StudentRouter = (router: Router, service: StudentService): void => {
router.get('/', async (req: Request, res: Response) => {
try {
const data = await service.GetStudents();
res.status(200).send(data)
import { StudentDA } from "../DA";
import { IStudent } from "../types/types";
import shortid from "shortid";
export class StudentService {
constructor(private studentDA: StudentDA) { }
public async GetStudents() {
try {
const data = await this.studentDA.GetStudents();