Skip to content

A blank canvas for any Node and TypeScript project, with only the most common and helpful (but lightweight) modules introduced. Use as a template to begin any new TypeScript with Nodejs project.

License

Notifications You must be signed in to change notification settings

tberey/typescript-node-fresh-start-template

Repository files navigation

Workflow Issues Version Stargazers Forks Contributors LinkedIn


Logo

Node.ts

A Fresh & Blank Template,
to start something new in TypeScript and Nodejs
Contents
  1. About
  2. Startup
  3. Usage
  4. Complete Setup Instructions
  5. Changelog
  6. Contributing
  7. Contact
  8. Acknowledgements


About This Project

This is a fresh & blank template, with some of the most common and helpful (but basic) modules included, as well as automatic logging configured out the box. After installation and starting the application, you will have a simple and empty HTTP REST Server hosted locally, ready-to-go. Everything inclusive of this template will be completely up to date, and updated each time it is installed, so it will never depreciate and is safe to use over time repeatedly. This is the perfect starting point for any project, as you can simply install this template and then start importing your own modules, or writing your own code, without any hassle. Completely compatible with any vision or modules.

A new project can be written in either TypeScript or JavaScript, without any further changes needed, however this template is set up and intended for TS, making use of it's typesetting, pre-compiling abilities, and simplicity in an object-oriented approach.

This template is completely unrestricted, and free for anyone to use, unlimited, with no credit or acknowledgements needed. There are no signs of any ownership, or personal touches, inside the codebase.


Tech Stack

  • Typescript - Write in TypeScript (or JS), Compiles down to JavaScript.
  • NodeJS - Node Runtime Environment.
  • ExpressJS - Server & Router Infrastructure Framework.
  • EJS - Serves Client Views.
  • ESLint - Code Parsing, Styling & Error Checking.
  • Mocha-Chai - Testing with Mocha Framework, using the Chai Library.
  • Nodemon - Restart Application without Compiling, on a Change to Watched Files.
  • Rimraf - Directory Cleaner Tool.
  • Dotenv - Project Secrets Stored in a Local .env File.
  • SimpleTxtLogger - Logging tool.
  • @types/* - Various JS->TS Typesetting modules, to import types. Needed to use a JavaScript module with TypeScript when strict settings are enabled, or to make use of TS only features against a imported module.

- See Complete Instructions to create this template yourself, without any of the extra optional modules.




Startup

For help or guidance in downloading and running the application, see the following subsections.


Prerequisites

You must have npm (node package manager) and Nodejs installed on your system!

  1. Update npm:
npm install npm@latest -g

Installation

  1. Clone/Download:
git clone https://github.com/tberey/typescript-node-fresh-start-template.git
  1. Install:
npm install
  1. Start:
npm run start




Usage

Endpoint Action/Desc. Full URI (hosted locally, for some port; e.g.: 3000, which is default for this template)
  • GET "/"
Homepage:
The client-side landing page.
  • "http://localhost:3000/"

Screenshots

Logging Sample
Screenshot#1




Complete Setup Instructions

The following steps are complete instruction to create this template, but without any of the extra modules, and begin a brand new project in Nodejs with TypeScript from a blank slate. The commands are shell commands, to be carried out in a terminal, console or other shell environment.

  1. Create a new local directory and change current directory to new one:
mkdir <PROJECT_NAME> && cd <PROJECT_NAME>
  1. Initialize a new package.json file:
npm init -y
  1. Install TypeScript dependencies:
npm i --save-dev typescript ts-node
  1. Initialize a new tsconfig.json file:
npx tsc --init
  1. [Optional] Some basic parameters to use in the tsconfig.json file. My settings for this file can be found here also, to copy & paste. Otherwise, adjust this further with own preferences, or leave it as is.
{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "declaration": true,
    "sourceMap": true,
    "outDir": "build",
    "rootDir": "./",
    "strict": true,
    "esModuleInterop": true
  }
}
  1. Create main.ts, the entry point into the application:
echo "console.log('Hello, World');" > main.ts
  1. [Optional] Some basic information and scripts, for the package.json file:
{
  "name": "<App-Name>",
  "version": "1.0.0",
  "description": "<App_Desc>",
  "main": "build/main.js",
  "types": "build/main.d.ts"
  "scripts": {
    "setup": "npm update && npm install",
    "build": "tsc",
    "start": "node build/main.js",
    "start:src": "ts-node main.ts"
  }
}
  1. [Optional] Install, compile and start application (it won't do much yet, but you're off to a running start now):
npm run setup
npm run build
npm run start

^ Step 8.: These commands require the optional Step 7 to have been followed, to work as intended.
'npm run setup' installs and updates the project and it's dependencies, 'build' will compile the project into browser/app runnable JS, and 'start' will run the project, from the compiled files in build. 'start:src' runs the project from the source TS file, so compilation is not necessary.




Roadmap

Below is the refined and confirmed roadmap, that has been planned for completion. See open issues and also the project board, for any other proposed features or known issues, which may not be listed below.

Feature/Task/Bugfix Details Version (if released) Notes
Bug#1 Bug details... 0.0.1 example#1
Feature#4 Feature details... example#2




Changelog

Version Date Changes
1.0.0 2021-07-09
  • Initial Commit.
  • Add initial directory structure and files.
  • Add Screenshots directory, and images.
  • Create and format README.md
1.0.1 2021-07-14
  • Removal of local SimpleTxtLogger file. Addition of SimpleTxtLogger as a npm module.
  • Update README.md
1.0.2 2021-08-01
  • Update tsconfig.
  • Update README.md
1.0.3 2021-08-03
  • Add Rollbar config and class.
  • Fix Spelling.
  • Update README.md




Contributing

Contributions are welcomed and, of course, greatly appreciated.

  1. Fork the Project.
  2. Create your Feature Branch (git checkout -b feature/Feature)
  3. Commit your Changes (git commit -m 'Add some Feature')
  4. Push to the Branch (git push origin feature/Feature)
  5. Open a Pull Request.




Contact

Tom Berey; Project Manager, Lead Developer, Principal Tester & Customer Services;
tomberey1@gmail.com;


Acknowledgements