8000 Enhance server capabilities · Issue #216 · ream/ream · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Nov 21, 2021. It is now read-only.

Enhance server capabilities #216

Open
krmax44 opened this issue Mar 6, 2021 · 1 comment
Open

Enhance server capabilities #216

krmax44 opened this issue Mar 6, 2021 · 1 comment

Comments

@krmax44
Copy link
krmax44 commented Mar 6, 2021

Currently, only very basic server logic can be implemented comfortably using Ream. Maybe using an enhance-server.ts file, server hooks could be used to implement for example middleware. Just one example:

// enhance-server.ts
export const onCreatedApp = ({ server }) => {  
  server.post('/api/register', (req) => {
    db.users.add({ username: req.query.username })
  })

  const websocket = new myWebsocketMiddleware()
  server.use(websocket)
}

Or possibly consolidated with the pages/api/ system:

// pages/api/users.ts
import { server } from '@ream/server'

server.use(authMiddleware) // middleware all /api/users/* routes
server.post('/register', handleRegistration) // mapped to /api/users/register
@egoist
Copy link
Collaborator
egoist commented Mar 6, 2021

Yeah I'm also thinking about this, will get my hands on it next week.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0