chore: Adds initial code.
This commit is contained in:
parent
a4ea6406e6
commit
939eb0b9d7
8 changed files with 1282 additions and 17 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -131,3 +131,6 @@ dist
|
|||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
*.db
|
||||
*.db-journal
|
7
dev.env
Normal file
7
dev.env
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Environment variables declared in this file are automatically made available to Prisma.
|
||||
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
|
||||
|
||||
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
||||
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
||||
|
||||
DATABASE_URL="file:./db/dev.db"
|
1157
package-lock.json
generated
1157
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -3,6 +3,7 @@
|
|||
"version": "1.0.0",
|
||||
"description": "Base TypeScript template to use",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "tsc",
|
||||
|
@ -13,7 +14,14 @@
|
|||
"author": "greysoh",
|
||||
"license": "BSD-3-Clause",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.12.7",
|
||||
"nodemon": "^3.0.3",
|
||||
"prisma": "^5.12.1",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prisma/client": "^5.12.1",
|
||||
"bcrypt": "^5.1.1",
|
||||
"fastify": "^4.26.2"
|
||||
}
|
||||
}
|
||||
|
|
43
prisma/migrations/20240417003924_init/migration.sql
Normal file
43
prisma/migrations/20240417003924_init/migration.sql
Normal file
|
@ -0,0 +1,43 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE "DesinationProvider" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"backend" TEXT NOT NULL,
|
||||
"connectionDetails" TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ForwardRule" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"sourceIP" TEXT NOT NULL,
|
||||
"sourcePort" INTEGER NOT NULL,
|
||||
"destIP" TEXT NOT NULL,
|
||||
"destPort" INTEGER NOT NULL,
|
||||
"destProviderID" INTEGER NOT NULL,
|
||||
"enabled" BOOLEAN NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Permission" (
|
||||
"permissionID" TEXT NOT NULL,
|
||||
"has" BOOLEAN NOT NULL,
|
||||
"userID" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
CONSTRAINT "Permission_userID_fkey" FOREIGN KEY ("userID") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
"email" TEXT NOT NULL,
|
||||
"name" TEXT,
|
||||
"rootToken" TEXT
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Permission_permissionID_key" ON "Permission"("permissionID");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
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 (i.e. Git)
|
||||
provider = "sqlite"
|
55
prisma/schema.prisma
Normal file
55
prisma/schema.prisma
Normal file
|
@ -0,0 +1,55 @@
|
|||
// 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"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model DesinationProvider {
|
||||
id Int @id @default(autoincrement())
|
||||
|
||||
name String
|
||||
description String?
|
||||
|
||||
backend String
|
||||
connectionDetails String
|
||||
}
|
||||
|
||||
model ForwardRule {
|
||||
id Int @id @default(autoincrement())
|
||||
|
||||
name String
|
||||
description String?
|
||||
|
||||
sourceIP String
|
||||
sourcePort Int
|
||||
|
||||
destIP String
|
||||
destPort Int
|
||||
|
||||
destProviderID Int
|
||||
enabled Boolean
|
||||
}
|
||||
|
||||
model Permission {
|
||||
permissionID String @unique
|
||||
has Boolean
|
||||
|
||||
user User @relation(fields: [userID], references: [id])
|
||||
userID Int @id @default(autoincrement())
|
||||
}
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
|
||||
email String @unique
|
||||
name String?
|
||||
|
||||
rootToken String?
|
||||
permissions Permission[]
|
||||
}
|
23
src/index.ts
23
src/index.ts
|
@ -1 +1,22 @@
|
|||
console.log("Hello, world!");
|
||||
import process from "node:process";
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import Fastify from "fastify";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const fastify = Fastify({
|
||||
logger: true
|
||||
});
|
||||
|
||||
fastify.get('/', async function handler (request, reply) {
|
||||
return { hello: 'world' };
|
||||
})
|
||||
|
||||
// Run the server!
|
||||
try {
|
||||
await fastify.listen({ port: 3000 });
|
||||
} catch (err) {
|
||||
fastify.log.error(err);
|
||||
process.exit(1);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue