equity-report-api v0.0.1
Equity Report API
Equity Report 2019 Typescript API
Usage
Installation
# using ssh
git clone git@github.com:SpacebarTech/equity-report-api
# using https
git clone https://github.com/SpacebarTech/equity-report-api.gitContributing
Folder structure
.vscode/
settings.json # disable Jest, use Typescript@x.y.z, etc.
snippets.code-snippets # project snippets.
bin/ # nodejs bin scripts.
nu.js # bin script to create all the things.
src/ # all project files.
controllers/ # route logic ONLY
{entity}/ # PLURAL; e.g. users, panes, etc.
{verb}/ # LOWERCASE; get, put, post, patch, delete, etc.
router.ts # the router itself.
validator.ts # the validator for a specific verb's router.
helpers/ # helper functions and enums, not including type defs.
enums/ # enums go here.
executeSproc.ts # the primary function of executing sprocs.
lib/ # business logic goes here.
{entity}/ # SINGULAR; logic for specific entity (e.g. user, pane, etc.)
repo.ts # the primary method of hitting a sproc for a given entity.
service.ts # calls repo method and transforms it for frontend.
index.ts # the entry-point of the project.
server.ts # server logic itself.
.editorconfig
.gitignore
.nvmrc
nodemon.json
README.md
package.json
tsconfig.json
tslint.jsonPath mapping
In Typescript, you can map paths
in order to avoid the use of ../../../../ all over the
place in your code. Each folder in src has a map as
specified in the tsconfig.json. So instead of writing
// src/lib/user/service.ts
import myHelperFunction from '../../helpers/myHelperFunction';You would now write
import myHelperFunction from 'helpers/myHelperFunction';nu
There's an available bin script called nu (pronounced
"new"). Executing this command will make a new entity
folder, with a repo and a service file, as well as will
make all necessary routers and validators.
nu <NAME>
Files generated:
/src/controllers/<NAME>/get/router.ts
/src/controllers/<NAME>/get/validator.ts
# remaining routers for other http verbs
/src/lib/<NAME>/repo.ts
/src/lib/<NAME>/service.tsYou can get access to this script by running the following:
chmod +x bin/nu.js && npm linkNotes
This project utilizes stored procedures
(or "sprocs" for short). Stored procedures remove most, if
not all, compiling overhead from queries as they are stored
directly in the database. Because of this, ObjectionJS
and Knex cannot be used as there will be no need to
perform SQL queries from the API.
Instead, an executeSproc (or similarly named) function
will be called to execute a specific query.
Due to the nature of sprocs and using a production database, tests may not be written for this project.
6 years ago