Git Product home page Git Product logo

app's People

Contributors

aquapi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

fgyweb

app's Issues

Cannot find module '@stricjs/app/send' or its corresponding type declarations.ts(2307)

this is fine no error lint. but not working, It will throw error: Cannot find module "@stricjs/app/lib/send" from xxx at console

import { text } from '@stricjs/app/lib/send';

this is fine but it has error. and its working xD wont throw error at console. but gonna throw at lint error swigly redline.
Cannot find module '@stricjs/app/send' or its corresponding type declarations.ts(2307)

import { text } from '@stricjs/app/send';

please fix typescript types xD me no like errors even tho it works still in editor its red line xD because i think u move the .d.ts on library lib instead of root.

image

Server-Sent Events giving `TypeError: undefined is not an object (evaluating 'c.signal.aborted')`

I tried out Server-Sent Events in Stric, but I keep running into an issue when I call my endpoint.

Here is the stacktrace:

1 | function anonymous(pull,abort,cancel,o
2 | ) {
3 | return c=>new Response(new ReadableStream({type:'direct',pull:_=>{while(!c.signal.aborted)pull(_,c);abort(_,c)},cancel:_=>{cancel(_,c)}}),o)
                                                                                                                                           ^
TypeError: undefined is not an object (evaluating 'c.signal.aborted')
      at pull (:3:136)
      at readDirectStream (:1:21)
GET - /sse failed

Here is my main.routes.ts:

import { routes } from '@stricjs/app';
import { events } from '@stricjs/app/stream';

export default routes()
  .get('/sse', (ctx) => {
    let interval: Timer | undefined;
    const evs = events((controller, ctx) => {
      interval = setInterval(() => {
        controller.write('hello');
      }, 1000);
    });
    evs.abort((controller, ctx) => {
      console.log('abort');
      clearInterval(interval);
    });
    evs.cancel((controller, ctx) => {
      console.log('cancel');
      clearInterval(interval);
    });

    return evs.send()(ctx);
  })

Not sure what signal.aborted is supposed to be on the, what I assume is, the context that is being passed in to the function returned from evs.send().

Let me know if I can help out in any way or if you have any other questions.

Thank you!

An error occurs if add a variable to the `fallback` function when there is no GET route

This code in file index.ts

import { init } from '@stricjs/app';

init({
    routes: ['./src'],
    fallback: function (ctx) {
        return new Response('404 - NotFound', { status: 404 })
    }
});

and this code in file src/index.routes.ts

import { routes } from "@stricjs/app";

export default routes()
    .post('/hello', () => new Response('Hello POST'))
 

and this is error log
Screenshot from 2024-02-16 18-14-44

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.