Git Product home page Git Product logo

utils's People

Contributors

aquapi avatar

Stargazers

NickAc avatar biTTer avatar  avatar Frédérique Mittelstaedt avatar Justin Powers avatar Muhammad Ubaid Raza avatar Heer Harmog avatar  avatar Brynne Taylor avatar noah edward hall avatar Johannes Meissner avatar Adrián Baena García avatar Scott Walter avatar

Watchers

Brynne Taylor avatar QuyCH avatar

utils's Issues

Static server not working

import { Router } from "@stricjs/router";
import { dir } from "@stricjs/utils";

export default new Router().all("/public/*", dir("./public"));

Display's Bun's standard "Welcome to Bun!" page. No error in console either.

Problem with response utility

When doing this:

import { response} from '@stricjs/utils';
const badReq = response('Bad request', { status: 400 });

I get the following error:

SyntaxError: Unexpected identifier 'request'. Expected ')' to end an argument list.
      at /home/rob/bun6/node_modules/@stricjs/utils/index.js:3:678

Looks like there may be an issue in that module?

SSE Client identification

The SSE documentation is extremely sparse and difficult to understand how to apply this functionality (I'm familiar with Fastify's SSE interface however, so I know how SSE can be used).

One thing I'd need to be able to do is to identify/recognise the individual connected clients - in Fastify that's done through req.id. Does Stric provide anything similar?

Also could you expand on how to use req.controller? Some simple examples would help

stream types missing in >= 2.0.6 after installing

I was following the quick start at https://bun.sh/guides/ecosystem/stric and encountered the following error:
SyntaxError: Export named 'dir' not found in module '/......./node_modules/@stricjs/utils/index.js'.

changing the dependencies in package.json:

  • "@stricjs/utils": "2.0.7"
    • bun i
    • find node_modules/@stricjs/utils/types | grep stream ==> nothing found
  • "@stricjs/utils": "2.0.6"
    • bun i
    • find node_modules/@stricjs/utils/types | grep stream ==> nothing found
  • "@stricjs/utils": "2.0.5"
    • bun i
    • find node_modules/@stricjs/utils/types | grep stream ==> 🎉 node_modules/@stricjs/utils/types/stream.d.ts

With "@stricjs/utils": "2.0.5" there's no such error.

Did I miss something or is it a bug?

Correctly handling invalid file names when using stream.dir

I want to be able to serve up static files, but want to be able to detect if an incoming file path doesn't actually exist.

I've noticed that the dir object has been replaced with stream.dir, so I've tried this:

`
import { Router } from '@stricjs/router';
import { stream } from '@stricjs/utils';
let router = new Router({port: 3000});
router.get('/*', stream.dir('./www'));

router.use(404, (req) => {
return Response.json({error: 'Unrecognised request'}, {status: 401});
});

export default router;
`

This will correctly return my index.html file from the www directory, but if I request indexy.html which doesn't exist, I get the response:

Welcome to Bun! To get started, return a Response object.

Is there a way to trap this and return a proper 404 response instead?

Parametric routes: identifying the matched URL path

Within the handler of a parametric route handler, is there a programmatic way to get the parametric URL path that was matched, eg:

    router.get('/token/:token', (req) => {
      // req.url returns the actual instance of the url that was sent
     //   is there a way to get the fact it matched /token/:token,
     //  other than hard-coding in each handler method logic? 
    });

Many thanks for any advice/suggestions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.