Giter Site home page Giter Site logo

haouarihk / prisma-accelerate-local Goto Github PK

View Code? Open in Web Editor NEW

This project forked from node-libraries/prisma-accelerate-local

0.0 0.0 0.0 762 KB

Prisma Accelerate functions locally on your behalf.

License: MIT License

JavaScript 6.49% TypeScript 93.51%

prisma-accelerate-local's Introduction

prisma-accelerate-local

Prisma Accelerate functionality can be self-hosted locally.

Samples

usage

CLI Options

Category Option Description
USAGE [option] <url>
ARGUMENTS <url> Datasource url
OPTIONS -t, --http Accepted at http
-p, --port <port> Port to listen on (default:4000)
-o, --host <host> Host to listen on (default:localhost)
-c, --cert <path> Path to ssl cert file
-k, --key <path> Path to ssl key file
-w, --wasm Use wasm as the run-time engine(early-access)
-s, --secret <secret> Secret used with API key
-m, --make make api key
-b, --bodyLimit <size(MB)> body limit size(default: 16MB)

CLI

Start without setting an API key for local use.

# Startup by specifying the Datasource url
npx prisma-accelerate-local postgresql://postgres:password@localhost:5432/postgres

# Startup by specifying Port
npx prisma-accelerate-local postgresql://postgres:password@localhost:5432/postgres -p 8000

When setting the API key

  • Create an API key
npx prisma-accelerate-local -s secret -m postgresql://postgres:password@localhost:5432/postgres

# Output
eyJhbGciOiJIUzI1NiJ9.eyJkYXRhc291cmNlVXJsIjoiYSIsImlhdCI6MTcwMzY2NDg1NywiaXNzIjoicHJpc21hLWFjY2VsZXJhdGUifQ.4ruaA1RAT9cD3PACSEVIdUs3i2exKkMpNYGks3hyos4
  • Activate with API key enabled.

If secret is used, the DB address is embedded in the API key

npx prisma-accelerate-local -s secret

Client Environment Variables

With regard to the Node.js configuration.

Please set the environment variable NODE_TLS_REJECT_UNAUTHORIZED because you are using an unauthenticated certificate.

With regard to api_key

  • If you are not using secret, the api_key can be any string.
  • If you are using secret, put --secret and the api_key created with --make in api_key

Example

  • .env
DATABASE_URL="prisma://localhost:4000/?api_key=API_KEY"
NODE_TLS_REJECT_UNAUTHORIZED="0"
# To remove the NODE_TLS_REJECT_UNAUTHORIZED warning
NODE_NO_WARNINGS="1"

library

If you call this package as a library, it will look like this.

import { createServer } from 'prisma-accelerate-local';

const server = createServer({
  datasourceUrl: 'postgresql://postgres:password@localhost:5432/postgres',
})
  .listen({ port: 4000 })
  .then((url) => console.log(`๐Ÿš€  Server ready at ${url} `));

prisma-accelerate-local's People

Contributors

haouarihk avatar mdluo avatar sorakumo001 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.