Skip to content

GDP-ADMIN/base-typescript-code

Repository files navigation

Base TypeScript Code

This is a TypeScript project template for TypeScript development in GDP Labs.

Please note that this is a general template. When you use TypeScript to start a project, you'll most likely use a more specific tech stack:

  1. For frontend, you'll probably use NextJS or Angular.
  2. For backend, you'll probably use NextJS, NestJS, or Express.
  3. For mobile, you'll probably use React Native.

Please apply the concept in this repo appropriately and adjust as necessary.

Minimum Requirements

  1. Node version 18 or higher.

Getting Started

  1. Install NVM if you haven't already. NVM will allow you to switch Node version easily.
  2. There's a list of recommended extension in .vscode/extensions.json. Install it by following this documentation.
    1. Open VSCode user settings and add the following settings for psioniq.psi-header extension. This will allow you to insert header comment by executing command Header Insert (Cmd+Shift+P then type > Header Insert):
  "psi-header.variables": [
    ["author", "Your name"],
    ["authoremail", "Your email"],
    ["modifyauthor", "Your name"],
    ["modifyauthoremail", "Your email"]
  ],
  "psi-header.templates": [
    {
      "language": "*",
      "template": [
        "<<filename>>",
        "DEFAULT DESCRIPTION. EDIT OR DELETE THIS.",
        "",
        "Authors:",
        "  <<author>> (<<authoremail>>)",
        "Created at: <<filecreated('MMMM Do YYYY')>>",
        "-----",
        "Last Modified: <<dateformat('MMMM Do YYYY')>>",
        "Modified By: <<modifyauthor>> (<<modifyauthoremail>>)",
        "-----",
        "Reviewers:",
        "  ",
        "---",
        "References:",
        "  NONE",
        "---",
        "Copyright (c) <<year>> GDP LABS. All rights reserved."
      ]
    }
  ],
  "psi-header.changes-tracking": {
    "isActive": true,
    "modAuthor": "Modified By: ",
    "modDate": "Last Modified: "
  },

Running Locally

  1. Run npm install.

This project is meant to be a sample. It's not runnable. When you create a TypeScript project, you'll most likely use a more specific tech-stack/framework (like the ones described in the beginning of this README) and each of them will provide a way to run the project.

Linting and Formatting

  1. If you use VSCode, the linting and formatting will be done automatically on save.
  2. If you need to run it programmatically, you can run the following scripts:
    1. npm run prettier: checking Prettier formatting.
    2. npm run prettier-fix: checking and fix Prettier formatting.
    3. npm run lint: checking lint using ESLint.
    4. npm run lint-fix: checking and fix lint using ESLint.

Test

  1. Run npm test.
  2. If you want to generate coverage report, run npm run test:coverage.

Deployment

Majority of CI/CD pipelines in GDP Labs will trigger CI/CD when there's a new push to the main branch.

Specific to this sample project, there's no deployment.

Folder & File Structure

These are short descriptions for each folder/file. Majority of individual files also contain header comments. Please check them out before trying to read the code.

Please note that this is a general template. View it as guideline and adjust accordingly to your project's needs.

  1. .vscode

It contains VSCode settings. It's recommended to use VSCode as your IDE.

extensions.json: contains recommended extensions. Install it by following this documentation.

settings.json: this will set the VSCode formatter to Prettier and make it format the code on save.

  1. src

Contains the source code for your project

  1. tests

Contains test source code for your project

  1. .eslintignore

Contains files and folders to be ignored by eslint configuration at ``.eslintrc.js`

  1. .eslintrc.js

Contains linting configuration for eslint

  1. .gitignore

Contains files & folders to be ignored by git.

  1. package-lock.json

Describes the dependency tree generated by installing dependencies in package.json.

  1. package.json

Various script and dependency list.

  1. README.md

This file.

  1. sonar-project.properties

Contains configuration for SonarQube, a sofware to analyze code quality.

  1. tsconfig.json

TypeScript configuration file.

  1. vitest.config.js

Configuration file for vitest, a Unit Test library.

References

  1. TypeScript Style Guide.
  2. Python Style Guide.

If you cannot access any of the references, please contact your manager or team lead.

Automatic Documentation Generation

For generating documentation using typedoc, you can run the following scripts: npm run generate-docs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published