{"id":13789127,"url":"https://github.com/jirutka/njs-typescript-starter","last_synced_at":"2025-10-06T20:17:45.487Z","repository":{"id":66269653,"uuid":"330286185","full_name":"jirutka/njs-typescript-starter","owner":"jirutka","description":"A starting template for developing njs (NGINX JavaScript) scripts for NGINX server in TypeScript.","archived":false,"fork":false,"pushed_at":"2023-07-02T10:44:15.000Z","size":45,"stargazers_count":47,"open_issues_count":1,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-12T03:43:53.415Z","etag":null,"topics":["nginx","njs","starter-template","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jirutka.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"jirutka"}},"created_at":"2021-01-17T00:38:27.000Z","updated_at":"2025-03-23T22:18:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"36752ed0-6b37-47dc-8090-9b5e3a65f96d","html_url":"https://github.com/jirutka/njs-typescript-starter","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/jirutka/njs-typescript-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fnjs-typescript-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fnjs-typescript-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fnjs-typescript-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fnjs-typescript-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jirutka","download_url":"https://codeload.github.com/jirutka/njs-typescript-starter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fnjs-typescript-starter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278672050,"owners_count":26025826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nginx","njs","starter-template","typescript"],"created_at":"2024-08-03T21:00:58.816Z","updated_at":"2025-10-06T20:17:45.460Z","avatar_url":"https://github.com/jirutka.png","language":"JavaScript","funding_links":["https://github.com/sponsors/jirutka"],"categories":["Njs Projects"],"sub_categories":["Lua Modules"],"readme":"= Njs TypeScript Starter\n:toc: macro\n:toc-title:\n:gh-name: jirutka/njs-typescript-starter\n// non-breakable hyphen\n:nb-: \u0026#8209;\n// links\n:Babel: link:https://babeljs.io[Babel]\n:ESLint: link:https://eslint.org[ESLint]\n:Mocha: link:https://mochajs.org[Mocha]\n:nginx-testing: link:https://github.com/jirutka/nginx-testing[nginx-testing]\n:Rollup: link:https://babeljs.io[Rollup]\n:yarn: link:https://yarnpkg.com/[yarn]\n:npm: link:https://docs.npmjs.com/cli/commands/npm/[npm]\n\nA full-featured starting template for developing https://github.com/nginx/njs[njs] (NGINX JavaScript) scripts for https://nginx.org[NGINX] server in https://www.typescriptlang.org[TypeScript].\n\nThis template uses {Babel} and {Rollup} to compile TypeScript sources into a single JavaScript file for njs and {Mocha} with {nginx-testing} for running integration tests against NGINX sever.\n\n\n[discrete]\n== Table of Contents\n\ntoc::[]\n\n\n== Pre-requisites\n\nTo build and run this project locally you will need:\n\n* Linux system footnote:[It should work on any recent Linux distribution for x86_64, aarch64, or ppc64le architecture.], macOS footnote:[I’m not sure what is the lowest version you need. It should work both on Intel and M1.] or Windows Subsystem for Linux (WSL) footnote:[njs doesn’t support Windows, so integration tests won’t run on Windows out of the box. If you’re stuck with Windows, WSL is the easiest way to go.]\n* https://nodejs.org/en/download/package-manager/[Node.js] 18.12 or newer\n* {npm} (distributed with Node.js) or {yarn}\n\n*NOTE:* You do *not* need Docker or other containerization tool for developing and testing njs scripts on Linux and macOS! See {nginx-testing} for more information.\n\n\n== Getting Started\n\n. Clone this repository:\n+\n[source, sh, subs=\"+attributes\"]\ngit clone --depth=1 https://github.com/{gh-name}.git \u003cproject-name\u003e\ncd \u003cproject-name\u003e\n\n. Install dependencies:\n+\n[source, sh]\nnpm install  # or yarn install\n\n. Build the project and run tests:\n+\n[source, sh]\nnpm test\n\n. Start nginx and project’s build in the watch mode:\n+\n[source, sh]\nnpm run start\n\n. Open http://127.0.0.1:8090/hello in the browser and now you should see the output of link:src/hello.ts[]:\n+\n....\n    Meow, world!\n\n        (\"`-''-/\").___..--''\"`-._\n        `6_ 6  )   `-.  (     ).`-.__.`)\n        (_Y_.)'  ._   )  `._ `. ``-..-'\n      _..`--'_..-_/  /--'_.' ,'\n      (il),-''  (li),'  ((!.-'\n....\n\nAt least *before publication* of your project (e.g. on GitHub), do the following:\n\n* Change _name_, _version_, _description_, _author_, _license_ (if you prefer a license other than MIT), _homepage_, _bugs_, and _repository_ fields in link:package.json[] to reflect your project.\n* Add your name to link:LICENSE[] and/or change the license text if you prefer a license other than MIT. You don’t have to keep my name in the license.\n* Replace this README file. If you prefer Markdown to AsciiDoc, replace this file with `README.md` and remove `scripts.prepublishOnly` from link:package.json[].\n\n\n== Project Structure\n\nFiles and directory structure of the project.\n\n[%header]\n|===\n| Path | Description\n\n| link:.github/workflows/[]\n| Contains https://github.com/features/actions/[GitHub Actions] workflows.\n\n| *link:dist/[]*\n| Contains the built JavaScript file for NGINX’s JS module.\n\n| *link:integration-tests/[integration{nb-}tests]*\n| Contains your integration tests.\n\n| lib/\n| Contains type declarations generated from TypeScript sources in `src/` directory.\n\n| node_modules/\n| Contains all your npm dependencies.\n\n| *link:src/[]*\n| Contains your source code that will be compiled to the `dist/` directory.\n\n| link:src/tsconfig.json[]\n| Config settings for type checking your TypeScript source code that will be compiled for njs.\n\n| link:.editorconfig[]\n| Defines very basic code style used in the project.\nSee https://editorconfig.org[editorconfig.org] for more information.\n\n| link:.eslintrc.js[]\n| {ESLint} config for linting your TypeScript and JavaScript files.\n\n| link:.mocharc.js[]\n| {Mocha} config for integration tests.\n\n| link:babel.config.js[]\n| {Babel} config for compiling TypeScript sources into plain JavaScript compatible with njs and Node.js.\n\n| *link:package.json[]*\n| File that contains npm dependencies as well as \u003c\u003cBuild Scripts, build scripts\u003e\u003e.\n\n| package{nb-}lock.json\n| Describes the exact dependency tree that was generated, including exact versions and checksums of the installed packages.\nThis file is automatically generated by {npm} when you run e.g. `npm install`.\n(https://docs.npmjs.com/cli/configuring-npm/package-lock-json[read more…])\n\n| link:rollup.config.js[]\n| {Rollup} config for compiling and bundling your source code in `src/` together with the dependencies into a single JavaScript file for NGINX JS module.\n\n| link:tsconfig.json[]\n| Config settings for type checking code written in TypeScript or JavaScript that will be executed by Node.js (i.e. integration tests and  JS configs).\n\n| yarn.lock\n| If you use {yarn} instead of {npm}; this file has the same purpose as _package-lock.json_ for npm.\n|===\n\n*NOTE:* Some of the files and directories will be created after installing dependencies or building the project.\n\n\n== Build Scripts\n\nAll the build steps are orchestrated via https://docs.npmjs.com/misc/scripts[npm scripts].\nNpm scripts basically allow us to call (and chain) terminal commands via npm.\nIf you open link:package.json[], you will see a scripts section with all the different scripts you can call.\nTo call a script, simply run `npm run \u003cscript-name\u003e` (or `yarn \u003cscript-name\u003e`) from the command line.\n\nBelow is a list of all the scripts this template has available:\n\n[%header, cols=\"m,d\"]\n|===\n| Npm{nbsp}Script | Description\n\n| build           | Compiles and bundles all source `.ts` files together with their dependencies into a single `.js` file in the `dist` directory.\n| clean           | Cleans `dist`, `lib`, and `node_modules/.cache` directories.\n| lint            | Runs both `lint:eslint` and `lint:types` in parallel.\n| lint:eslint     | Runs {ESLint} linter on project files.\n| lint:types      | Runs TypeScript type checker on project files.\n| start           | Runs `start-nginx` and `watch` in parallel.\n| start{nb-}nginx | Starts nginx 1.24.x on port 8090 with config `integration-tests/nginx.conf` and reloads it on each change of the config file and files in `dist/`.\n| test            | Runs all tests in the `integration-tests` directory using {Mocha} test runner.\n| watch           | Same as `build` but continuously watches project’s `.ts` files and re-compiles when needed.\n|===\n\n\n== Dependencies\n:npmjs-pkg: https://www.npmjs.com/package/\n\nProject’s dependencies are specified in file link:package.json[], sections `dependencies` (runtime dependencies) and `devDependencies` (build-time dependencies).\nThey are managed by {npm} or {yarn}.\n\nThe following is a list of `devDependencies` with their description.\n\n* {npmjs-pkg}/typescript[typescript] -- TypeScript compiler and type checker. Used for type checking the TypeScript sources.\n** {npmjs-pkg}/njs-types[njs-types] -- TypeScript type definitions for njs.\n** @types/* -- Packages that provide TypeScript types.\n\n* {npmjs-pkg}/@babel/core[@babel/core] -- A {Babel} compiler core. Babel is used to compile TypeScript sources into plain JavaScript compatible with njs and Node.js.\n** {npmjs-pkg}/babel-preset-njs[babel-preset-njs] -- A {Babel} preset for transforming JavaScript code with modern language features into code compatible with njs.\n** {npmjs-pkg}/@babel/preset-typescript[@babel/preset-typescript] -- A {Babel} preset to transform TypeScript code into plain JavaScript. It basically just strips the type annotations.\n** {npmjs-pkg}/@babel/plugin-transform-modules-commonjs[@babel/plugin-transform-modules-commonjs] -- A {Babel} plugin to transform ES2015 modules into CommonJS modules. Used for running integration tests with Node.js.\n** {npmjs-pkg}/@babel/register[@babel/register] -- A {Babel} require hook. Used for {Mocha} integration with TypeScript.\n** {npmjs-pkg}/babel-register-ts[babel-register-ts] -- A `@babel/register` wrapper with additional `.ts` and `.tsx` extensions. Used for {Mocha} integration with TypeScript.\n\n* {npmjs-pkg}/rollup[rollup] -- A module bundler for JavaScript which compiles small pieces of code into a single JavaScript file.\n** {npmjs-pkg}/@rollup/plugin-babel[@rollup/plugin-babel] -- A {Rollup} plugin for seamless integration between Rollup and {Babel}.\n** {npmjs-pkg}/@rollup/plugin-commonjs[@rollup/plugin-commonjs] -- A {Rollup} plugin to convert CommonJS modules to ES6, so they can be included in a Rollup bundle.\n** {npmjs-pkg}/@rollup/plugin-node-resolve[@rollup/plugin-node-resolve] -- A {Rollup} plugin which locates modules using the Node resolution algorithm, for using third party modules in `node_modules`.\n** {npmjs-pkg}/rollup-plugin-add-git-msg[rollup-plugin-add-git-msg] -- A {Rollup} plugin that inserts git tag, commit hash, build date and copyright at top of the generated JS bundle.\n\n* {npmjs-pkg}/mocha[mocha] -- A flexible JavaScript test framework for Node.js.\n** {npmjs-pkg}/mocha-suite-hooks[mocha-suite-hooks] -- Suite-level hooks for {Mocha}; allows to run hook before/after describe block.\n\n* {npmjs-pkg}/nginx-testing[nginx-testing] -- Support for integration/acceptance testing of nginx configuration.\n\n* {npmjs-pkg}/got[got] -- A human-friendly and powerful HTTP request library for Node.js. Used in integration tests. Do _not_ update it to version 12.x (see https://github.com/{gh-name}/issues/3[#3])!\n\n* {npmjs-pkg}/eslint[eslint] -- {ESLint} is a tool for identifying and reporting on patterns found in JavaScript and TypeScript code.\n** {npmjs-pkg}/@typescript-eslint/eslint-plugin[@typescript-eslint/eslint-plugin] -- A TypeScript plugin for {ESlint}.\n** {npmjs-pkg}/@typescript-eslint/parser[@typescript-eslint/parser] -- An {ESLint} parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.\n\n* {npmjs-pkg}/npm-run-all[npm-run-all] -- A CLI tool to run multiple npm-scripts in parallel or sequential. Used in npm scripts.\n\n\n== License\n\nThis project is licensed under https://opensource.org/license/mit/[MIT License].\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirutka%2Fnjs-typescript-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjirutka%2Fnjs-typescript-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirutka%2Fnjs-typescript-starter/lists"}