Development and Production Ready |⸰| VSCode Extensions
Expose all the knobs |⸰| As lean as a racehorse can get |⸰| Fork and keep as an upstream, then create your own endpoints
The skeleton-tg-endpoint is a graphql-endpoint API starterkit/boilerplate. This skeleton demonstrates digesting remote third-party APIs to provide an experiential graphql gateway used by clients (primarily web, but as a developer API too).
- Configuration is primarily driven by ENV variables (required are set in .env.example).
- An express server is the foundation of this service.
- Several express middlewares are applied for a production class setup.
- Then Apollo Server and GraphiQL (Playground) are attached to the server with their middlewares.
The preferred way of authorizing a client to pull data is for them to request a JWT from an authorization service, and providing this key for subsequent data requests.
Setting this up is outside the scope of the skeleton. A tutorial will be included here (TODO: write graphql auth enpdoint tutorial).
"dependencies": {},
"devDependencies": {
"@tgrx/tslint-config-tgr": "5.0.0", # TGR tslint settings for minimial clutter- First, clone this repo to your local machine
- Change the remote name
git remote rename origin upstream - Create a new repository in github/gitlab
- Add the new remote
git remote add origin <your-new-address>
When updates for the upstream are available, merge them into your skeleton
git pull upstream master
# Handle merge conflicts if necessary
git commit # commit the changes if necessary
git push origin masterAfter you've cloned this repo and ran npm i -D, do the following:
in your terminal:
$ nps ss
# Starts the dev server* nps # Executes all the tooling (watch server + watch linting)
* nps start.server # Nodemon and webpack builds restart when files change
* nps help # Displays all available commands
* nps commit # Creates a commit, don't use `git commit -m ...`
* nps build # Builds a development version of the service
* nps build.prod # Builds a production version of the service (w/ some testing - overidable)
* nps lint # Lint checks the module
* nps test # Test checks the modulesrc/
├── __tests__/ - TODO: tests for stack.ts
├── config/ - server configs and vars
├── gql/ - schema, resolvers, mutations for GraphQL
├── middlewares/ - third-party HOC functionality (apollo, loggers, routers)
├── modules/ - first-party modules (co-developed)
└── some-lib - pre-cursor to extracting a module
├── service/ - service initialization (express, apollo, storybook)
├── types/ - ts modules, common, interfaces
├── utils/ - useful functions
├── index.ts - build/service entry point
└── stack.ts - import service & middlewares
/
├── .netlify/ - pretty good for rolling builds (hidden)
├── .vscode/ - some sane settings but hides lightly used folders (hidden)
├── build/ - the output of the webpack build process (hidden)
├── jest/ - Jest setup and mocks (hidden)
├── logs/ - Store logs in files (configged by `module/logger`)
├── node_modules/ - the output of `npm i -D` (hidden)
├── scripts/ - LOOK IN HERE, all the functionality avail in `nps`
├── src/ - LOOK IN HERE, the server
└── <DESCRIBED IN-DEPTH ABOVE>
├── webpack/ - Webpack configuration for making builds (hidden)
├── .babelrc - transpilation settings mixed w/ tsconfig (hidden)
├── .env - server environment's settings (removed by `.gitignore`)
├── .env.development - suggestions for development env settings
├── .env.example - a list of required `.env` settings
├── .gitignore - a list of files that should not be checked into git (hidden)
├── .npmignore - a list of files that should not be published to npm (hidden)
├── .npmrc - npm install settings (package-lock.json disabled) (hidden)
├── .nvmrc - nvm config that sets the terminals NPM version (hidden)
├── jest.config.js - npm install settings (package-lock.json disabled) (hidden)
├── nodemon.json - configure nodemon (especially which directories to ignore) (hidden)
├── package-scripts.js - nps entry point (reroutes to `/scripts/`) (hidden)
├── package.json - list of npm packages to be installed
├── README.md - the most important documentation
├── TODO.md - checklist of goals for the project
├── tsconfig.jest.json - Jest specific Typescript configuration (hidden)
├── tsconfig.json - Typescript settings and module aliasing (hidden)
└── tslint.json - Linting settings (**replaced by ESlint 2019Q3**) (hidden)
Accessing Hidden Files from VSCode
If you are using VSCode to develop this project you will notice a lot of files are hidden by the editor. This is a workspace setting which you can access with ctrl+p ./vscode/settings.json. Any file/folder which is set to true in "files.exclude" is automatically excluded by "search.exclude". So to make the workspace settings file available in the search but hidden in the file explorer (left sidebar) the file must be specified in "search.exclude" and set to false.
This way files are accessible by search but your sidebar isn't cluttered w/ lightly used configs
- 🌐
express-server - 🍞 in dev a browser to the website is opened
- 🚞
Winstonunified logger to files and console - 🔒
Helmetfor common security holes - 🔒
CORSfor Cross Origin denial
- 📡
apollo-server-2 - 😋
playground(notgraphiqlbecause using JWT instead of sessions) - ➿
apollo-serverw/subscriptions(websocket)
- 🚦
webpack-graphql-loaderfor separating gql from ts files
- 🚀 ES2018+ support syntax that is stage-3 or later in the TC39 process.
- 🎛 Preconfigured to support development and optimized production builds
- 🎶
typescriptincremental returns reducing development bugs
- 🎮
npsnode-package-scripts removes the limitation of package.json enabling JS & //comments . Modify/package-scripts.jsand usenps <command>instead ofnpm run <command>. - 🙌
commitizento help us generate beautifully formatted and consistent commit messages. - 😹
cz-emojiis a plugin for commitizen that adds emoji to the commit template. - 🏆
standard-versionis a replacement fornpm versionwith automatic CHANGELOG generation - ✅
commitlintvalidates commit messages to follow commitizen patterns
- 🚦
tslintconfigured for strict, consistent, code style - 🚦
eslintreplacing TSLint in 2019Q3 - 🚦
ts-prettierfor some of that code-consistancy that's missing from tslint - 🚦
SonarTSStatic code analyzer detects bugs and suspicious patterns
- 🎭
jestas the test framework. - 🎭
ts-jestconfigured to test TS files, uses tsconfig.jest.json, and skip babel. - 🎭
enzymemakes it easier to assert, manipulate, and traverse components.
- 📦 All source is bundled using Webpack v4
- 🌟 webpack for dev, prod, common
- 🚦
ts-loaderfor compiling typescript - 💦 babel-loader for additional polyfills (browser support)
- 😎 HappyPack
- 🤖 Auto generated Vendor DLL for smooth development experiences
- 🍃 Tree-shaking