Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how do you run the server locally? #37

Closed
carcinocron opened this issue Nov 27, 2019 · 1 comment
Closed

how do you run the server locally? #37

carcinocron opened this issue Nov 27, 2019 · 1 comment

Comments

@carcinocron
Copy link

npm run dev, npm run start, npx micro, npx prismy don't work and the readme doesn't actually say what to run the server locally.

@Rokt33r
Copy link
Member

Rokt33r commented Jul 30, 2020

Prismy returns a handler for Node.js's HttpServer. So you can run it like

import http from 'http'
import { prismy, querySelector, res } from 'prismy'

const handler = prismy([querySelector], query => {
  return res(query)
})
const port = process.env.PORT || 3000

const server = new http.Server(handler)

server.listen(port)
console.log(`Hosting... http://localhost:${port}`)

Please check our examples! https://github.com/prismyland/prismy/blob/master/examples/basic-server/src/scripts/serve.ts

@Rokt33r Rokt33r closed this as completed Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants