@prisma/dev
Advanced tools
| interface StartServerOptions { | ||
| /** | ||
| * The port the Accelerate server will listen on. | ||
| * | ||
| * Defaults to `5433`. | ||
| * | ||
| * An error is thrown if the port is already in use. | ||
| */ | ||
| acceleratePort?: number; | ||
| /** | ||
| * The port the database server will listen on. | ||
| * | ||
| * Defaults to `5432`. | ||
| * | ||
| * An error is thrown if the port is already in use. | ||
| */ | ||
| databasePort?: number; | ||
| } | ||
| interface Server { | ||
| accelerate: { | ||
| url: string; | ||
| }; | ||
| close(): Promise<void>; | ||
| database: { | ||
| connectionString: string; | ||
| }; | ||
| ppg: { | ||
| url: string; | ||
| }; | ||
| } | ||
| declare function unstable_startServer(options?: StartServerOptions): Promise<Server>; | ||
| export { type Server, type StartServerOptions, unstable_startServer }; |
| import { createRequire } from 'module'; const require = createRequire(import.meta.url); | ||
| import{createHash as S}from"crypto";import{createServer as b}from"http2";import{promisify as h}from"util";import{serve as g}from"@hono/node-server";import{Hono as u}from"hono/tiny";function m(){let e,o,t=new Promise((r,a)=>{e=r,o=a});return{fail:o,promise:t,succeed:e}}async function p(e,o){let t=new u;t.use(async(s,i)=>{s.set("db",o),await i()}),t.route("/",v);let{fail:r,promise:a,succeed:c}=m(),n=g({createServer:b,fetch:t.fetch,port:e},()=>{c()});return n.on("error",s=>{if(typeof s=="object"&&"code"in s&&s.code==="EADDRINUSE")return r({portNotAvailable:e});console.error(s)}),await a,{async close(){await h(n.close.bind(n))()},port:e,url:`http://localhost:${e}`}}var d=new Map,v=new u;v.put("/:clientVersion/:schemaHash/schema",async e=>{let{req:o}=e,t=await o.text(),r=o.param("schemaHash");return t===d.get(r)?e.text(r):r!==w(t)?e.text("hashes do not match",500):(d.set(r,t),e.text(r))});function w(e){return S("sha256").update(e).digest("hex")}import{promisify as y}from"util";import{PGlite as P}from"@electric-sql/pglite";import{createServer as D}from"pglite-server";async function f(e){let o="default",t="postgres",r=new P({database:o,dataDir:"memory://",username:t});await r.waitReady;let a=D(r),{fail:c,promise:n,succeed:s}=m();return a.on("error",i=>{"code"in i&&i.code==="EADDRINUSE"&&c(new Error(`Port ${e} is already in use. Provide a different \`dbport\` number and try again.`))}),a.listen(e,()=>s()),await n,{async close(){try{await y(a.close.bind(a))()}finally{await r.close()}},connectionString:`postgres://${t}@localhost:${e}/${o}`,database:o,port:e,username:t}}async function q(e){let{acceleratePort:o=5433,databasePort:t=5432}=e||{},r=await f(t),a=await p(o,r);return{accelerate:{url:a.url},close:()=>c([a,r]),database:{connectionString:r.connectionString},ppg:{url:`prisma+postgres://localhost:${a.port}/?dbname=${r.database}&dbport=${r.port}&dbuser=${r.username}`}};async function c(n){let i=(await Promise.allSettled(n.map(l=>l.close()))).filter(l=>l.status==="rejected").map(l=>new Error(l.reason));if(i.length>0)throw new AggregateError(i,"Failed to close some servers")}}export{q as unstable_startServer}; |
+13
-9
| { | ||
| "name": "@prisma/dev", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "description": "A local Prisma Postgres server for development and testing", | ||
| "type": "module", | ||
| "main": "./dist/index.js", | ||
@@ -18,8 +19,2 @@ "module": "./dist/index.js", | ||
| }, | ||
| "scripts": { | ||
| "build": "tsup", | ||
| "check:exports": "attw . --pack", | ||
| "lint": "eslint --fix .", "test": "", | ||
| "typecheck": "tsc --noEmit" | ||
| }, | ||
| "keywords": [ | ||
@@ -45,4 +40,13 @@ "prisma", | ||
| "@hono/node-server": "1.14.1", | ||
| "hono": "4.7.8" | ||
| "hono": "4.7.8", | ||
| "pglite-server": "0.1.4" | ||
| }, | ||
| "scripts": { | ||
| "build": "tsup", | ||
| "check:exports": "attw . --pack", | ||
| "dev": "tsup --watch", | ||
| "lint": "eslint --fix .", | ||
| "test": "", | ||
| "typecheck": "tsc --noEmit" | ||
| } | ||
| } | ||
| } |
| interface StartServerOptions { | ||
| /** | ||
| * An abort signal to stop the server abruptly. | ||
| */ | ||
| abortSignal?: AbortSignal; | ||
| onStart?: (port: number) => void; | ||
| /** | ||
| * The port the server will listen on. | ||
| * | ||
| * Defaults to `5433`. | ||
| * | ||
| * An error is thrown if the port is already in use. | ||
| */ | ||
| port?: number; | ||
| } | ||
| declare function unstable_startServer(options?: StartServerOptions): Promise<void>; | ||
| export { type StartServerOptions, unstable_startServer }; |
| import { createRequire } from 'module'; const require = createRequire(import.meta.url); | ||
| import{createServer as s}from"http2";import{serve as S}from"@hono/node-server";import{Hono as p}from"hono/tiny";var m=new p,o=m;async function l(e){let{abortSignal:a,onStart:n,port:i=5433}=e||{};await new Promise((c,t)=>{a?.addEventListener("abort",()=>t(new Error("aborted")),{once:!0});try{S({createServer:s,fetch:o.fetch,port:i},r=>n?.(r.port))}catch(r){t(r)}})}export{l as unstable_startServer}; |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
4054
107.26%42
1300%Yes
NaN4
33.33%4
33.33%+ Added
+ Added