initial commit
This commit is contained in:
commit
3bf77835dd
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
dist/
|
||||||
|
node_modules/
|
||||||
|
generated/prisma
|
||||||
|
package-lock.json
|
||||||
|
.env
|
||||||
|
*.db
|
||||||
|
*.db-journal
|
5
devnote.txt
Normal file
5
devnote.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
moving from knex to prisma
|
||||||
|
|
||||||
|
read more:
|
||||||
|
https://github.com/prisma/prisma-examples/blob/latest/orm/express/src/index.ts
|
||||||
|
https://www.prisma.io/docs/getting-started
|
44
package.json
Normal file
44
package.json
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"name": "relay",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"start": "node ./dist/app.js",
|
||||||
|
"dev": "npx ts-node -r tsconfig-paths/register ./src/app.ts",
|
||||||
|
"build": "sh ./scripts/build.sh",
|
||||||
|
"build:client": "npx tsc -p ./src/client/tsconfig.json",
|
||||||
|
"build:server": "npx tsc -p ./tsconfig.json",
|
||||||
|
"build:tailwind": "npx @tailwindcss/cli -i ./src/client/public/css/main.css -o ./src/client/public/css/tailwind.css",
|
||||||
|
"db:migrate": "npx prisma migrate dev --name",
|
||||||
|
"db:seed": "npx prisma db seed"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"description": "",
|
||||||
|
"devDependencies": {
|
||||||
|
"@tailwindcss/cli": "^4.1.4",
|
||||||
|
"@types/ejs": "^3.1.5",
|
||||||
|
"@types/express": "^5.0.1",
|
||||||
|
"@types/jquery": "^3.5.32",
|
||||||
|
"@types/node": "^22.14.1",
|
||||||
|
"@zerollup/ts-transform-paths": "^1.7.18",
|
||||||
|
"nodemon": "^3.1.9",
|
||||||
|
"prisma": "^6.6.0",
|
||||||
|
"tailwindcss": "^4.1.4",
|
||||||
|
"tsc-alias": "^1.8.15",
|
||||||
|
"typescript": "^5.8.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@prisma/client": "^6.6.0",
|
||||||
|
"dotenv": "^16.5.0",
|
||||||
|
"ejs": "^3.1.10",
|
||||||
|
"ejs-mate": "^4.0.0",
|
||||||
|
"express": "^5.1.0",
|
||||||
|
"sqlite3": "^5.1.7",
|
||||||
|
"tsconfig-paths": "^4.2.0"
|
||||||
|
},
|
||||||
|
"prisma": {
|
||||||
|
"seed": "ts-node prisma/seed.ts"
|
||||||
|
}
|
||||||
|
}
|
5
prisma/migrations/20250421224829_init/migration.sql
Normal file
5
prisma/migrations/20250421224829_init/migration.sql
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "TestModel" (
|
||||||
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"name" TEXT
|
||||||
|
);
|
10
prisma/migrations/20250421230249_init/migration.sql
Normal file
10
prisma/migrations/20250421230249_init/migration.sql
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the `TestModel` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- DropTable
|
||||||
|
PRAGMA foreign_keys=off;
|
||||||
|
DROP TABLE "TestModel";
|
||||||
|
PRAGMA foreign_keys=on;
|
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Please do not edit this file manually
|
||||||
|
# It should be added in your version-control system (e.g., Git)
|
||||||
|
provider = "sqlite"
|
13
prisma/schema.prisma
Normal file
13
prisma/schema.prisma
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// This is your Prisma schema file,
|
||||||
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||||
|
|
||||||
|
generator client {
|
||||||
|
provider = "prisma-client-js"
|
||||||
|
output = "../generated/prisma"
|
||||||
|
}
|
||||||
|
|
||||||
|
datasource db {
|
||||||
|
provider = "sqlite"
|
||||||
|
url = env("DATABASE_URL")
|
||||||
|
}
|
||||||
|
|
18
scripts/build.sh
Normal file
18
scripts/build.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
echo "Building project..."
|
||||||
|
|
||||||
|
rm -rf ./dist
|
||||||
|
cd "$(dirname "$0")/../"
|
||||||
|
|
||||||
|
echo "Compiling backend..."
|
||||||
|
npm run build:server
|
||||||
|
|
||||||
|
echo "Compiling frontend..."
|
||||||
|
npm run build:tailwind
|
||||||
|
npm run build:client
|
||||||
|
|
||||||
|
echo "Copying client files..."
|
||||||
|
mkdir -p ./dist/client
|
||||||
|
cp -r ./src/client/public ./dist/client/public
|
||||||
|
cp -r ./src/client/views ./dist/client/views
|
||||||
|
|
||||||
|
echo "Build complete!"
|
26
src/app.ts
Normal file
26
src/app.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import dotenv from "dotenv";
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
|
import path from "path";
|
||||||
|
import express from "express";
|
||||||
|
import engine from "ejs-mate";
|
||||||
|
|
||||||
|
import homeRouter from "@server/routers/home.router";
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
app.engine("ejs", engine);
|
||||||
|
app.set("view engine", "ejs");
|
||||||
|
app.set("views", path.resolve(__dirname, "client/views"));
|
||||||
|
app.use(express.urlencoded({ extended: true }));
|
||||||
|
|
||||||
|
app.use("/static", express.static(path.resolve(__dirname, "client/public")));
|
||||||
|
|
||||||
|
app.use("/", homeRouter);
|
||||||
|
|
||||||
|
const HOST = process.env.HOST || "localhost";
|
||||||
|
const PORT = process.env.PORT || 3000;
|
||||||
|
|
||||||
|
app.listen(PORT, () => {
|
||||||
|
console.log(`Server is listening on port http://${HOST}:${PORT}`);
|
||||||
|
});
|
0
src/client/public/css/main.css
Normal file
0
src/client/public/css/main.css
Normal file
0
src/client/public/css/tailwind.css
Normal file
0
src/client/public/css/tailwind.css
Normal file
0
src/client/public/js/placeholder.js
Normal file
0
src/client/public/js/placeholder.js
Normal file
11
src/client/tsconfig.json
Normal file
11
src/client/tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES5",
|
||||||
|
"outDir": "./public/js",
|
||||||
|
"rootDir": "./typescript",
|
||||||
|
"sourceMap": false
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"./typescript/**/*"
|
||||||
|
]
|
||||||
|
}
|
0
src/client/typescript/placeholder.ts
Normal file
0
src/client/typescript/placeholder.ts
Normal file
3
src/client/views/home.ejs
Normal file
3
src/client/views/home.ejs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<% layout("layout/base") -%>
|
||||||
|
|
||||||
|
home page
|
18
src/client/views/layout/base.ejs
Normal file
18
src/client/views/layout/base.ejs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title><%= title %></title>
|
||||||
|
<link rel="stylesheet" href="/static/css/tailwind.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<%- include("sidebar") -%>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<%- body -%>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%- block("scripts").toString() %>
|
||||||
|
</body>
|
||||||
|
</html>
|
1
src/client/views/layout/sidebar.ejs
Normal file
1
src/client/views/layout/sidebar.ejs
Normal file
@ -0,0 +1 @@
|
|||||||
|
sidebar
|
7
src/server/controllers/home.controller.ts
Normal file
7
src/server/controllers/home.controller.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
|
const get = async (_request: Request, response: Response) => {
|
||||||
|
response.render("home", { title: "home page" });
|
||||||
|
};
|
||||||
|
|
||||||
|
export default { get }
|
8
src/server/routers/home.router.ts
Normal file
8
src/server/routers/home.router.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
import controller from "@server/controllers/home.controller";
|
||||||
|
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
router.get("/", controller.get);
|
||||||
|
|
||||||
|
export default router;
|
1
src/types/ejs-mate.d.ts
vendored
Normal file
1
src/types/ejs-mate.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
declare module "ejs-mate";
|
31
tsconfig.json
Normal file
31
tsconfig.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES6",
|
||||||
|
"module": "CommonJS",
|
||||||
|
"rootDir": "./",
|
||||||
|
"baseUrl": "./",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"lib": [
|
||||||
|
"ES6",
|
||||||
|
"DOM"
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@server/*": ["./src/server/*"]
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
{"transform": "@zerollup/ts-transform-paths"}
|
||||||
|
],
|
||||||
|
"typeRoots": [
|
||||||
|
"./node_modules/@types",
|
||||||
|
"./src/types"
|
||||||
|
],
|
||||||
|
"sourceMap": false,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"./src/*",
|
||||||
|
"./src/server/**/*"
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user