Giter VIP home page Giter VIP logo

Comments (7)

alexproca avatar alexproca commented on July 16, 2024 1

Sure you can assign it to me! I will do it at the end of the week. I always wanted to extract express utils in a library like this but somehow managed not to do it. Your project is exactly the right thing I needed for migrating an older project in the brave new world of typescript.

from tsed.

Romakita avatar Romakita commented on July 16, 2024

The module serve-static can do that. No ?

class ServerLoader {
     $onMountingMiddlewares(){
           const serveStatic =   require('serve-static');
           this.getExpressApp()
                 .use(serveStatic('app'))
                 .use('/css', serveStatic('css-files'));
     }
}

from tsed.

alexproca avatar alexproca commented on July 16, 2024

Yes it can do it and it will do it. The proposal is only syntactic sugar. If one have to implement this he have to be careful with __directory because the path should be absolute, to use Path.resolve and so on. This would be very intuitive; you only have to add the route and the directory. May be even extended to nested static routes:

@Static({
  '/css': {
    'old': './old-css-files',
    'new': './new-css-files'
  },
  'public': './public'
})

Usually syntactic sugar shrinks the room for errors. ;)

from tsed.

Romakita avatar Romakita commented on July 16, 2024

Ok Alex :) you can propose your implementation of this decorator !

from tsed.

Romakita avatar Romakita commented on July 16, 2024

You are assigned to this task :D

from tsed.

alexproca avatar alexproca commented on July 16, 2024

Cool thanks. You can assign #13 to me too.

from tsed.

Romakita avatar Romakita commented on July 16, 2024

Implemented with the new decorator

@ServerSettings({
   "serveStatic": {
      "\": "webapp"
   }
})
class Server extends ServerLoader {}

from tsed.

Related Issues (20)

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.