Questions tagged [oak]

For questions about Oak, the middleware framework for Deno's net server

77 questions
2
votes
1 answer

Why am i receiving this (error: TS2376) while running oak.? Details of error in body

I have this simple server.ts file. import { Application, Router } from "https://deno.land/x/oak/mod.ts"; const app = new Application(); const router = new Router(); router .get("/",(ctx) => { ctx.response.body = "Router has been created"; //…
Crocodile
  • 43
  • 4
2
votes
2 answers

error: TS2339 [ERROR]: Property x does not exist ... on Deno compile

This is my first time using Oak and Deno. I learn it from https://www.robinwieruch.de/deno-oak-rest-api and documentation. I want to use REST-API deno using this script (server.ts). import { v4 } from 'https://deno.land/std/uuid/mod.ts'; import { …
astridx
  • 6,581
  • 4
  • 17
  • 35
1
vote
1 answer

Deno Oak web-server - force redirect http to https

Is there a way to catch all http traffic and redirect it to https using Deno / Deno and Oak while also serving https? I have a simple Deno web-server using the Oak middleware. I have it set up for https and everything works when connecting using…
Woodsy
  • 160
  • 10
1
vote
0 answers

Connection refused when requesting Deno server (with oak middleware) from NextJS api routes

I'm trying to request Deno server from next api routes. To simplify (with the same result), let's assume we have server written with oak middleware like: import { Application } from 'https://deno.land/x/oak/mod.ts' import { oakCors } from…
olegzhermal
  • 799
  • 10
  • 26
1
vote
1 answer

Deno Oak: How to send an object with many blobs in only one response to the Web Browser

I am using Deno, with the Oak framework. I want to send a FormData object as a response from the server, because I want to send (in only one response, instead of making many calls) an object which contains many blobs (for example, a group of…
Imagitori
  • 55
  • 5
1
vote
2 answers

oak on Deno - How do I build a URL to a route?

I come from a land of ASP.NET Core. Having fun learning a completely new stack. I'm used to being able to: name a route "orders" give it a path like /customer-orders/{id} register it use the routing system to build a URL for my named route An…
Luke Puplett
  • 42,091
  • 47
  • 181
  • 266
1
vote
1 answer

Deno oak server post body and reponse

I use oak server with Deno. But there is some problem with the response in post request. My example: const loginEp = async (ctx, next) => {//loginEp if(!ctx.request.hasBody) {//if ctx.throw(415); }//if const reqBody = await…
QSpider
  • 537
  • 2
  • 10
1
vote
1 answer

Not able to set cookie in browser with Deno Oak

I am trying to set up Authentication with Deno, Oak and JWT. Objective: Send cookie with jwt token in the response. Set cookie in the browser Use the cookie for subsequent requests. Route: Cookie being set export const getUsers = async ({…
sgrmhdk
  • 230
  • 1
  • 8
1
vote
1 answer

Can oak server hook into deno's std serve server?

Given an existing native deno http server like this: import {serve} from "https://deno.land/std@0.153.0/http/server.ts"; import { handle } from './astro/dist/server/entry.mjs'; serve((req: Request) => { console.log(req) return…
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
1
vote
1 answer

How to return html file on specific path in deno?

I have a very basic deno app with oak module to build the http server. I want to send a http file, the index.html, only when the path is / (not /anyotherpath). From oak's github I have this code app.use(async (ctx, next) => { try{ await…
Tinaira
  • 727
  • 2
  • 7
  • 23
1
vote
1 answer

ctx.cookies.set() vs setCookies in Deno std

I'm currently working with Deno (Oak framework), and wanted to know what is the difference between using Oak's ctx.cookies (https://github.com/oakserver/oak/blob/main/cookies.ts) vs something from Deno's std lib (setCookies, getCookie, and…
zachary
  • 27
  • 5
1
vote
1 answer

Property '' does not exist on type 'Promise | Promise| Promise | FormDataReader | Promise|undefined'.deno-ts

I am a new Deno learner following a tutorial video. The following code is a part of the tutorial's Authentication file code. As it's written by previous version of Deno has some errors that I could resolve most of them except the following…
user11874694
1
vote
1 answer

How to dynamically create routes?

I'm trying to dynamically add routes to my api by iterating over an array of objects called route groups. A route group can have many routes. Here are my types (the RouterContext type comes from Oak middleware framework): // routes/mod.ts type Route…
1
vote
0 answers

Getting Current context in Oak with Typescript Class Syntax

I'm struggling with the following scenario using Deno with Oak. Most tutorials use export const xy = () => {} syntax, when they separate controllers and routes. In the route then they commonly have something like router.get("/the-route", xy), which…
bquarta
  • 559
  • 6
  • 19
1
vote
1 answer

post request using oak in deno with mongodb

I'm new to deno, and I'm trying to create a post request with oak following this tutorial by freecodecamp (https://www.youtube.com/watch?v=TQUy8ENesGY). And I realized that many things changed and it took me hours to find those many things using…
user10033434
  • 402
  • 5
  • 19