0.1.1 • Published 5 years ago

node.ts-cli v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

alt-text

A Node CLI for generating Node.js API using Typescript and Express.

This project was created as practice for creating Node CLIs, working with Node/Typescript, as well as Promises and Async/await.

:package: Getting Started

At this stage Node.ts is not meant to be used as a production development tool, but if you find it useful for your projects I would love to hear about it, If you feel like contributing to the project, by all means fork the repo and make a pull request with any enhancements or bug fixes, I'm sure there are plenty.

:electric_plug: Installing

Node.ts is available as a npm package. To install globally run:

npm install -g node.ts

That's it! If globally installed, Node.ts will create your new project in the current directory of your terminal.

:file_folder: File Structure

The structure of the project is loosely based off of Microsoft's Typscript + Node starter project structure. Below is the output of creating a new Node.ts project:

NameDescription
distContains the distributable (or output) from your TypeScript build. This is the code you ship
node_modulesContains all your npm dependencies
srcContains your source code that will be compiled to the dist dir
src/configPassport authentication strategies and login middleware. Add other complex config code here
src/controllersControllers define functions that respond to various http requests
src/modelsModels define Mongoose schemas that will be used in storing and retrieving data from MongoDB
src/publicStatic assets that will be used client side
src/typesHolds .d.ts files not found on DefinitelyTyped.
src/app.tsHandler for your routes/controllers
src/server.tsEntry point to your express app
__tests__Contains your tests. Separate from source because there is a different build process.
.envAPI keys, tokens, passwords, database URI. Clone this, but don't check it in to public repos.
.gitignoreGitignore file, containing dist, node_modules, and env by default
jest.config.jsUsed to configure Jest running tests written in TypeScript
package.jsonFile that contains npm dependencies.
staticAssets.tsBuild script that copies images, fonts, and JS libs to the dist folder
tsconfig.jsonConfig settings for compiling server code written in TypeScript
tslint.jsonConfig settings for TSLint code style checking

:hammer: Commands

Create a new Node.ts project:
node.ts new/n <projectName>

You will be asked a few simple questions, after which, the project will be created in a directory of the same name, a tsconfig.json, package.json, package-lock.json, jest.config.js, and tslint.json will be built. Git will be initiaized locally and a initial commit will be completed with your new project structure. Afterwards the dependencies will be downloaded.


:clipboard: v0.2.0 and Beyond

  • Fixing the many bugs that will arise...
  • Add command to create new models/controllers through the CLI
  • Unit testing
  • More boilerplate files in new projects, to speed up development
  • CLI Option to create Node.ts CLI application rather than API Server

For any other suggestions, or requests, either post an issue, or feel free to add yourself!

:lock: License

This project is licensed under the MIT License.