@ocsoftware/lamware-prisma 2.0.1
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/README.md +52 -0
- package/build/index.d.ts +7 -0
- package/build/index.js +1 -0
- package/build/index.mjs +1 -0
- package/build/types.d.ts +2 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://www.npmjs.com/package/@ocsoftware/lamware-prisma" target="_blank">
|
|
3
|
+
<img src="https://img.shields.io/npm/v/@ocsoftware/lamware-prisma?style=flat-square" alt="NPM" />
|
|
4
|
+
</a>
|
|
5
|
+
<a href="https://discord.gg/3S6AKZ2GR9" target="_blank">
|
|
6
|
+
<img src="https://img.shields.io/discord/123906549860139008?color=7289DA&label=discord&logo=discord&logoColor=FFFFFF&style=flat-square" alt="Discord" />
|
|
7
|
+
</a>
|
|
8
|
+
<img src="https://img.shields.io/npm/l/@ocsoftware/lamware-prisma?style=flat-square" alt="Apache-2.0" />
|
|
9
|
+
<h3>Lamware - Prisma ORM</h3>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
This [Lamware](https://github.com/evilkiwi/lamware) Middleware allows you to initialize and memoize your [Prisma](https://prisma.io) Client.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
This package is available via NPM:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
yarn add @ocsoftware/lamware-prisma
|
|
20
|
+
|
|
21
|
+
# or
|
|
22
|
+
|
|
23
|
+
npm install @ocsoftware/lamware-prisma
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import type { APIGatewayProxyHandlerV2 } from 'aws-lambda';
|
|
30
|
+
import { PrismaClient } from '@prisma/client';
|
|
31
|
+
import { prisma } from '@ocsoftware/lamware-prisma';
|
|
32
|
+
import { lamware } from '@ocsoftware/lamware-core';
|
|
33
|
+
|
|
34
|
+
const { handler } = lamware<APIGatewayProxyHandlerV2<any>>()
|
|
35
|
+
// You can provide your PrismaClient directly.
|
|
36
|
+
.use(prisma(PrismaClient))
|
|
37
|
+
|
|
38
|
+
// Or an (a)synchronous set-up closure.
|
|
39
|
+
.use(prisma(async () => {
|
|
40
|
+
return new PrismaClient();
|
|
41
|
+
}))
|
|
42
|
+
|
|
43
|
+
.execute(async ({ state }) => {
|
|
44
|
+
const user = await state.prisma.user.findUnique({
|
|
45
|
+
where: { id: 1 },
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return { statusCode: 200 };
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export { handler };
|
|
52
|
+
```
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PrismaClientOptions } from 'prisma/prisma-client/runtime';
|
|
2
|
+
import type { Middleware } from '@ocsoftware/lamware-core';
|
|
3
|
+
import type { Handler } from 'aws-lambda';
|
|
4
|
+
import type { PrismaClientStub, SetupFunction } from './types';
|
|
5
|
+
export declare const prisma: <C extends PrismaClientStub>(client: C | SetupFunction<C>, options?: PrismaClientOptions) => Middleware<Handler, {
|
|
6
|
+
prisma: InstanceType<C>;
|
|
7
|
+
}>;
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var m=(t,r)=>{for(var i in r)e(t,i,{get:r[i],enumerable:!0})},u=(t,r,i,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of o(r))!p.call(t,n)&&n!==i&&e(t,n,{get:()=>r[n],enumerable:!(s=a(r,n))||s.enumerable});return t};var c=t=>u(e({},"__esModule",{value:!0}),t);var d={};m(d,{prisma:()=>l});module.exports=c(d);var l=(t,r)=>({id:"prisma",init:async()=>C(t)?{prisma:new t(r)}:{prisma:await t()}}),C=t=>typeof t=="function"&&/^class\s/.test(Function.prototype.toString.call(t));0&&(module.exports={prisma});
|
package/build/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=(t,r)=>({id:"prisma",init:async()=>i(t)?{prisma:new t(r)}:{prisma:await t()}}),i=t=>typeof t=="function"&&/^class\s/.test(Function.prototype.toString.call(t));export{e as prisma};
|
package/build/types.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ocsoftware/lamware-prisma",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Lamware Middleware for initializing and memoizing Prisma ORM",
|
|
5
|
+
"files": [
|
|
6
|
+
"build"
|
|
7
|
+
],
|
|
8
|
+
"main": "./build/index.js",
|
|
9
|
+
"module": "./build/index.mjs",
|
|
10
|
+
"types": "./build/index.d.ts",
|
|
11
|
+
"license": "GPL-3.0-only",
|
|
12
|
+
"author": {
|
|
13
|
+
"name": "Evil Kiwi Limited",
|
|
14
|
+
"url": "https://evil.kiwi",
|
|
15
|
+
"email": "support@evil.kiwi"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/evilkiwi/lamware",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/evilkiwi/lamware/issues"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/evilkiwi/lamware.git"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"lambda",
|
|
27
|
+
"middleware",
|
|
28
|
+
"typescript"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"prepack": "pnpm run build",
|
|
35
|
+
"build": "node build.mjs && tsc",
|
|
36
|
+
"lint": "eslint --ext .ts,vue --ignore-path .gitignore src"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@ocsoftware/lamware-core": "^2.0.1"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@ocsoftware/lamware-core": "^2.0.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/aws-lambda": "^8.10.114",
|
|
46
|
+
"@types/node": "^18.15.5",
|
|
47
|
+
"esbuild": "^0.17.12",
|
|
48
|
+
"eslint": "^8.36.0",
|
|
49
|
+
"prisma": "^4.11.0",
|
|
50
|
+
"tslib": "^2.5.0",
|
|
51
|
+
"typescript": "^5.0.2"
|
|
52
|
+
}
|
|
53
|
+
}
|