npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rippell/ts-express

v0.0.1

Published

Start a quick and dirty Express JS server that live-interprets Typescript, scanning your project for controllers

Downloads

3

Readme

TS-Express

Start a quick and dirty Express JS server that live-interprets Typescript, scanning your project for controllers.

//TODO: -[ ] Watch and reload files -[ ] Plugin structure (add support for things like GraphQL) -[ ] Optionally enable Mongoose (peer dependency installation of course) -[ ] Testing.......

Install

npm i @rippell/ts-express -D

Then add a execution to package.json scripts.

    ...
    "scripts": {
      "start": "ts-express",
      "debug": "ts-express-debug"
    }
    ...

ts-express-debug starts node with --inspect to allow debugging (go to chrome://inspect and click Open dedicated DevTools for Node).


Then all .ts files under /src will be found by default. All files that export a endpoint object will attempt to be registered with the Express Router.

Endpoint object should adhere to the EndpointSet interface. Here's an example:

import { EndpointSet } from "@rippell/ts-express";

export const endpoints: EndpointSet = {
  '/v1/my-endpoint': {
    get:    (req, res) => { return   { cool:     'beans!'  } }, // Can Return an object
    post:   (req, res) => { res.json({ also:     'neat!'   })}, // Or send it yourself
    put:    (req, res) => { return   { too:      'many'    } },
    patch:  (req, res) => { return   { examples: 'to'      } },
    delete: (req, res) => { return   { cover:    'cleanly' } },
  },
  '/v1/another': {
    get: (req, res) => { return { moar: 'endpoints!' } }
  }
}

Optionally add a tsexpress.ts file at your project root, exporting a config: TSExpressConfig to configure TS-Express.

import { TSExpressConfig } from '@rippell/ts-express';

export const config: TSExpressConfig = {
  port: 9999
}

See Configuration below for more.

Out of the box

Express

Express is configured with:

Configuration

The following configuration is used out of the box:

{
    fileGlob:  'src/**/!(*.d).ts', // Any files under /src that end in .ts (but not .d.ts)
    host:      '0.0.0.0',          // Start and expose (convenience for containers or container-based IDEs like Eclipse-CHE)  
    port:      8080,               // Expose on 8080
    watch:     false,              // Don't set up watches by default
    verbose:   false               // Don't flood logs with TS-Express logging
}

See all available configuration in the TSExpressConfig interface.

As mentioned, a tsexpress.ts may be supplied at the project root, but all settings are overridden by environment variables in support of containerization. See env object for which values are pulled from the environment.