🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@prisma/dev

Package Overview
Dependencies
Maintainers
8
Versions
843
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma/dev - npm Package Compare versions

Comparing version
0.0.1
to
0.0.2
+33
dist/index.d.ts
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};