Questions tagged [polka]

6 questions
8
votes
1 answer

A Sapper-compatible setup to serve multiple apps from a single Express/Polka entry point

I need to set up a Polka (or Express) server so that it can serve multiple applications (one per hostname) from a single server.js entry point. It can be done using the vhost middleware (https://github.com/expressjs/vhost). Each app is exported as a…
3
votes
1 answer

Correctly closing Polka server when testing it with Jest and Supertest

I have the following Jest test that runs against a Polka server: import polka, {Polka} from 'polka'; import { agent as request } from 'supertest'; function brokenMiddleware(req, res, next) { throw new…
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
0
votes
1 answer

Failed to fetch Error - How do I send an axios response in Polka?

I try to fetch login datas in a Svelte/Sapper app as in the code below and I use polka and axios for the api request on the server. I don't understand the behaviour in the axios call. The console.log(JSON.stringify(result.data)) logs the correct…
Jaqen
  • 23
  • 4
0
votes
1 answer

Extend Polka Request object using Typescript

First of all, I know this topic looks really similar to this other topic talking about extending Express Request object using Typescript Basically, I try to do the same thing but with Polka this time Has anyone managed to do this? The path I…
Volubyl
  • 25
  • 1
  • 6
0
votes
1 answer

Sapper & Polka Authentication

I'm trying to create a simple authentication via arangodb (arangojs) using svelte & sapper as well as polka. So I'm fairly unexperienced in the node server stuff. In my login.svelte I'm sending a request: const response = await fetch("/login", { …
pgalle
  • 216
  • 3
  • 13
-1
votes
2 answers

How do you set the response status code in Polka.js framework

Seems like it should be simple. Trying: res.status(500).send({ error: "That type already exists." }) Gets me: TypeError: res.status is not a function This is in sapper, not sure if that makes a diff.
mtyson
  • 8,196
  • 16
  • 66
  • 106