@gonihost/prisma 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build-release.yml +37 -0
- package/package.json +31 -0
- package/prisma/schema.prisma +30 -0
- package/prisma.config.ts +14 -0
- package/src/index.ts +11 -0
- package/src/lib/prisma.ts +10 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Node.js Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
issues: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build-and-publish:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: 20
|
|
26
|
+
registry-url: https://registry.npmjs.org/
|
|
27
|
+
|
|
28
|
+
- run: npm ci
|
|
29
|
+
|
|
30
|
+
- run: npx prisma generate
|
|
31
|
+
|
|
32
|
+
- run: npm run build
|
|
33
|
+
|
|
34
|
+
- run: npm publish
|
|
35
|
+
env:
|
|
36
|
+
GIT_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
37
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gonihost/prisma",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"prisma:introspect": "dotenv -- prisma introspect",
|
|
12
|
+
"prisma:generate": "prisma generate"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"type": "commonjs",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^25.0.3",
|
|
20
|
+
"@types/pg": "^8.16.0",
|
|
21
|
+
"prisma": "^7.2.0",
|
|
22
|
+
"tsx": "^4.21.0",
|
|
23
|
+
"typescript": "^5.9.3"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@prisma/adapter-pg": "^7.2.0",
|
|
27
|
+
"@prisma/client": "^7.2.0",
|
|
28
|
+
"dotenv": "^17.2.3",
|
|
29
|
+
"pg": "^8.16.3"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// This is your Prisma schema file,
|
|
2
|
+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
3
|
+
|
|
4
|
+
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
5
|
+
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
6
|
+
|
|
7
|
+
generator client {
|
|
8
|
+
provider = "prisma-client"
|
|
9
|
+
output = "../src/generated/prisma"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
datasource db {
|
|
13
|
+
provider = "postgresql"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
model User {
|
|
17
|
+
id Int @id @default(autoincrement())
|
|
18
|
+
email String @unique
|
|
19
|
+
name String?
|
|
20
|
+
posts Post[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
model Post {
|
|
24
|
+
id Int @id @default(autoincrement())
|
|
25
|
+
title String
|
|
26
|
+
content String?
|
|
27
|
+
published Boolean @default(false)
|
|
28
|
+
author User @relation(fields: [authorId], references: [id])
|
|
29
|
+
authorId Int
|
|
30
|
+
}
|
package/prisma.config.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// This file was generated by Prisma, and assumes you have installed the following:
|
|
2
|
+
// npm install --save-dev prisma dotenv
|
|
3
|
+
import "dotenv/config";
|
|
4
|
+
import { defineConfig } from "prisma/config";
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
schema: "prisma/schema.prisma",
|
|
8
|
+
migrations: {
|
|
9
|
+
path: "prisma/migrations",
|
|
10
|
+
},
|
|
11
|
+
datasource: {
|
|
12
|
+
url: process.env["DATABASE_URL"],
|
|
13
|
+
},
|
|
14
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Context } from "vm";
|
|
2
|
+
import { prisma } from "./lib/prisma";
|
|
3
|
+
|
|
4
|
+
export * from "./generated/prisma/client";
|
|
5
|
+
|
|
6
|
+
export const createContext = async (ctx: any): Promise<Context> => {
|
|
7
|
+
// Skip if you are not using a serverless environment
|
|
8
|
+
ctx.callbackWaitsForEmptyEventLoop = false;
|
|
9
|
+
|
|
10
|
+
return { ...ctx, prisma };
|
|
11
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import { PrismaPg } from "@prisma/adapter-pg";
|
|
3
|
+
import { PrismaClient } from "../generated/prisma/client";
|
|
4
|
+
|
|
5
|
+
const connectionString = `${process.env.DATABASE_URL}`;
|
|
6
|
+
|
|
7
|
+
const adapter = new PrismaPg({ connectionString });
|
|
8
|
+
const prisma = new PrismaClient({ adapter });
|
|
9
|
+
|
|
10
|
+
export { prisma };
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "src",
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
|
|
6
|
+
"target": "ES2019",
|
|
7
|
+
"module": "CommonJS",
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"declarationMap": false,
|
|
12
|
+
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"strict": true,
|
|
15
|
+
"skipLibCheck": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src"]
|
|
18
|
+
}
|