Skip to content

Commit

Permalink
Replace nodemon with tsx, update TypeORM entities with types that are…
Browse files Browse the repository at this point in the history
… now needed
  • Loading branch information
floscher committed Jun 20, 2024
1 parent f3333db commit 38410a8
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 158 deletions.
180 changes: 41 additions & 139 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"type": "module",
"scripts": {
"start": "nodemon ./src/index.ts",
"start": "tsx watch ./src/index.ts",
"build": "tsc",
"lint": "prettier --check 'src/**/*.(ts|vue)' && eslint src/**/*.ts",
"lintfix": "prettier 'src/**/*.(ts|vue)' --write && eslint src/**/*.ts --fix"
Expand Down
5 changes: 2 additions & 3 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Backend Server for Blog in Node/Express",
"main": "server.js",
"scripts": {
"start": "NODE_ENV='development' NODE_EXTRA_CA_CERTS=../certs/ca.crt nodemon -r dotenv/config ./src/server.ts",
"start": "NODE_ENV='development' NODE_EXTRA_CA_CERTS=../certs/ca.crt tsx watch -r dotenv/config ./src/server.ts",
"write-app-version": "git describe --always --dirty > dist/app_version.txt",
"build": "tsc && npm run write-app-version",
"run-prod": "node ./dist/server.js",
Expand Down Expand Up @@ -43,10 +43,9 @@
"@typescript-eslint/eslint-plugin": "^8.0.0-alpha.30",
"@typescript-eslint/parser": "^8.0.0-alpha.30",
"node-fetch": "^3.3.1",
"nodemon": "^2.0.20",
"openid-client": "^5.4.0",
"prettier": "^3.3.2",
"ts-node": "^10.9.1",
"tsx": "^4.15.6",
"typescript": "^5.0.4"
}
}
2 changes: 1 addition & 1 deletion server/src/entity/Attachment.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class AttachmentEntity implements Attachment {
@PrimaryGeneratedColumn()
id?: number;

@Column({ nullable: false })
@Column({ nullable: false, type: "varchar" })
filename: string;

@JoinColumn({ name: "post_id", referencedColumnName: "id" })
Expand Down
4 changes: 2 additions & 2 deletions server/src/entity/OAuthAccount.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { UserEntity } from "./User.entity.js";
export class OAuthAccountEntity implements OAuthAccount {
@PrimaryGeneratedColumn()
id?: number;
@Column({ nullable: false, name: "oauth_id" })
@Column({ nullable: false, name: "oauth_id", type: "varchar" })
oauthId: string;

@ManyToOne(() => UserEntity, (user: UserEntity) => user.id)
@JoinColumn({ name: "user_id" })
user: UserEntity;
@Column({ type: "enum", enum: OAUTH_TYPES, nullable: false })
type: OAuthType;
@Column({ nullable: false })
@Column({ nullable: false, type: "text" })
domain: string;
}
14 changes: 7 additions & 7 deletions server/src/entity/Post.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ export class PostEntity implements Post {
@PrimaryGeneratedColumn()
id?: number;

@Column()
@Column("varchar")
title: string;

@Column({ nullable: true })
@Column({ nullable: true, type: "varchar" })
description: string;

@Column({ nullable: true })
@Column({ nullable: true, type: "varchar" })
markdown: string;

@Column({ name: "sanitized_html", nullable: true })
@Column({ name: "sanitized_html", nullable: true, type: "varchar" })
sanitizedHtml: string;

@Column({ name: "created_at" })
@Column({ name: "created_at", type: "timestamp" })
createdAt: Date;

@JoinColumn({ name: "created_by_id", referencedColumnName: "id" })
@ManyToOne(() => UserEntity)
createdBy?: UserEntity;

@Column({ name: "updated_at", nullable: true })
@Column({ name: "updated_at", nullable: true, type: "timestamp" })
updatedAt?: Date;

@JoinColumn({ name: "updated_by_id", referencedColumnName: "id" })
Expand All @@ -41,7 +41,7 @@ export class PostEntity implements Post {
@OneToMany(() => AttachmentEntity, (attachment) => attachment.post, { nullable: true })
attachments: AttachmentEntity[];

@Column({ nullable: false })
@Column({ nullable: false, type: "boolean" })
draft: boolean;

@ManyToMany((type) => TagEntity, (tag) => tag.posts, {
Expand Down
2 changes: 1 addition & 1 deletion server/src/entity/Tag.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class TagEntity implements Tag {
@PrimaryGeneratedColumn()
id?: number;

@Column({ nullable: false, unique: true })
@Column({ nullable: false, unique: true, type: "varchar" })
name: string;

@ManyToMany(() => PostEntity, (post) => post.tags)
Expand Down
8 changes: 4 additions & 4 deletions server/src/entity/User.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ export class UserEntity implements User {
@PrimaryGeneratedColumn()
id?: number;

@Column({ nullable: false })
@Column({ nullable: false, type: "varchar" })
username: string;

@Column({ name: "is_active", nullable: false })
@Column({ name: "is_active", nullable: false, type: "boolean" })
isActive: boolean;

@Column({ nullable: true, type: "text", name: "profile_picture_url" })
profilePictureUrl?: DataUrl;

@Column({ nullable: true, name: "full_name" })
@Column({ nullable: true, name: "full_name", type: "varchar" })
fullName?: string;

@Column({ unique: true, nullable: false })
@Column({ unique: true, nullable: false, type: "varchar" })
email: string;
@Column({ type: "enum", enum: Object.keys(UserRoles), array: true, nullable: false })
roles: UserRole[];
Expand Down

0 comments on commit 38410a8

Please sign in to comment.