Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
✨ Add interface for user
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Apr 23, 2019
1 parent d8b333e commit e4c8cab
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 307 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
"start": "concurrently 'yarn watch-build' 'yarn watch-prettier' 'yarn watch-server'",
"watch-build": "onchange '{src,examples}/**/*.ts' -- yarn build",
"watch-prettier": "onchange '{src,examples}/**/*.{ts,json}' -- prettier --write {{changed}}",
"watch-server": "nodemon dist/examples/express.js"
"watch-server": "nodemon dist/index.js"
},
"devDependencies": {
"@types/dotenv": "^6.1.1",
"@types/express": "^4.16.1",
"@types/jest": "^24.0.11",
"@types/mysql": "^2.15.5",
"@types/node": "^11.13.6",
"concurrently": "^4.1.0",
"coveralls": "^3.0.3",
Expand All @@ -30,7 +31,6 @@
},
"dependencies": {
"mysql": "^2.17.1",
"reflect-metadata": "^0.1.13",
"typeorm": "^0.2.16"
"reflect-metadata": "^0.1.13"
}
}
17 changes: 17 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import express from "express";
// import { create } from "./helpers/crud";

const app = express();

app.get("/", (req, res) => res.json({ hello: "world" }));
app.get("/create-account", async (req, res) => {
try {
// res.json({ success: true, data: await create() });
res.json({ success: true });
} catch (error) {
console.log("Error", error);
res.json({ success: false });
}
});

app.listen(process.env.PORT || 7007, () => console.log("App running"));
37 changes: 37 additions & 0 deletions src/interfaces/tables/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { QueryTable, NumberColumn, StringColumn, DateColumn, BooleanColumn } from "type-sql";

export interface User {
id: number;
name: string;
nickname: string;
primaryEmail?: number;
password: string;
twoFactorEnabled?: boolean;
twoFactorSecret?: boolean;
country?: string;
timezone?: string;
notificationEmails?: 1 | 2 | 3 | 4;
preferredLanguage?: string;
prefersReducedMotion?: boolean;
createdAt?: Date;
updatedAt?: Date;
}

export class UserTable extends QueryTable<User, number> {
id = new NumberColumn(this, "id");
name = new StringColumn(this, "name");
nickname = new StringColumn(this, "nickname");
primaryEmail = new NumberColumn(this, "primaryEmail");
password = new StringColumn(this, "password");
twoFactorEnabled = new BooleanColumn(this, "twoFactorEnabled");
twoFactorSecret = new StringColumn(this, "twoFactorSecret");
country = new StringColumn(this, "country");
timezone = new StringColumn(this, "timezone");
notificationEmails = new NumberColumn(this, "notificationEmails");
preferredLanguage = new StringColumn(this, "preferredLanguage");
prefersReducedMotion = new BooleanColumn(this, "prefersReducedMotion");
createdAt = new DateColumn(this, "createdAt");
updatedAt = new DateColumn(this, "updatedAt");
}

export const USER = new UserTable("User");
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"outDir": "./dist",
"typeRoots": ["node_modules/@types"]
},
"include": ["src/**/*.ts", "examples/**/*.ts"],
"include": ["src/**/*.ts"],
"exclude": ["node_modues"]
}
Loading

0 comments on commit e4c8cab

Please sign in to comment.