Skip to content

barelyhuman/todo-challege-30-min

Repository files navigation

todo-challenge-30-min

For the tweet: https://twitter.com/barelyreaper/status/1691543793248657408
Speed run video: https://youtu.be/ld8bBI0RtK0

thestack

I spent the time making the decisions so you don't have to.

What comes bundled

  • Simpler Express based server
  • Decorators + Classes for Routing
class Auth {
  @post('/auth/signup')
  async signup(req, res) {
    // handler
  }
}
  • Typed (Mostly...)
  • Basic Security (Helmet, Rate Limiting, CORS)
  • API testing (Vitest + Mock Server)
  • ORM (prisma)
  • Migrations (prisma)
  • Queue (bull + redis)
  • Decorators for Queue Handling based on Worker execution
  • View Engine (Nunjucks)
class User {
  @post('/user/invite')
  sendInvite(req, res) {
    const email = req.body.email
    req.pushToQueue('email', {
      email,
      type: 'invite',
    })
  }
}
// jobs/email.queue.ts
class EmailQueueHandler {
  @listen('email', 'invite')
  handleInviteJob(job) {
    // Called from the worker
    // process the job
  }
}
  • Compose (Self host services for dev / k8s)
  • Fully Docker compatible
  • Testing Mocks (Redis)
  • Swagger Doc generation using JSDoc - Documentation
  /**
   *
   * GET /api/ping
   * @summary quickly check if the server is running or not
   * @returns 200 - success - application/json
   */
  @get('/api/ping')
  ping(req: Request, res: Response) {
    req.pushToQueue('test', {
      type: '',
    })
    return res.send({
      success: true,
      now: new Date().toISOString(),
    })
  }

Why?

Various reasons...., this might be relevant

License

MIT