1
Setup your environment
First, you need to install and be familiar the following:
git
node
andpnpm
node
and npm
. The recommended method is using the n
version
manager if you are on MacOS or Linux. Make sure you are using the
active LTS version of
Node.Next install pnpm.2
Fork the repository
Follow
these instructions
to
fork
and clone the repository
(
express-rate-limit/express-rate-limit
).Once you have forked and cloned the repository, you can
pick out an issue
you want to fix/implement!3
Install the dependencies
Run
pnpm install --frozen-lockfile
to install the JavaScript dependencies.If there are errors, try deleting the node_modules
folder first, then re-run
the install command.4
Create a branch
Once you have cloned the repository to your computer (say, in
While naming your branch, make sure the name is short and self explanatory.Once you have created a branch, you can start coding!
~/Code/express-rate-limit
) and picked the issue you want to tackle, create a
branch based off the main
branch:terminal
5
Writing code
The library is written in
typescript
and supports node
versions 16, 18
and 20. The code is arranged as follows:Code Structure
Code Structure
Most files have a little description of what they do at the top.
6
Documentation and testing
When adding a new feature or fixing a bug, please update the documentation and
changelog as well as add tests for the same. Also make sure the codebase passes
the linter and library tests by running
npm test
. Note that running
npm run format
will automatically resolve most style/lint issues.Note that the external tests require various datastores to be installed locally
and take more time to execute. Typically they are run only on GitHub Actions.
You may run these tests locally by running
npm run test:ext
.7
Making a commit
Once you have made changes to the code, you will want to
commit (basically, Git’s version of
save) the changes. To commit the changes you have made locally:While writing the
terminal
commit-message
, try to follow the below guidelines:- Prefix the message with
type:
, wheretype
is one of the following depending on what the commit does:fix
: Introduces a bug fix.feat
: Adds a new feature.test
: Any change related to tests.perf
: Any performance related change.meta
: Any change related to the build process, workflows, issue templates, etc.refc
: Any refactoring work.docs
: Any documentation related changes.
- Keep the first line brief, and less than 60 characters.
- Try describing the change in detail in a new paragraph (double newline after the first line).
husky
and lint-staged
will automatically lint the
code and fix most issues. In case an error is not automatically fixable, they
will cancel the commit. Please fix the errors before committing the changes. If
you still wish to commit the changes, prefix the git commit
command with
HUSKY=0
, like so:terminal
8
Pushing your changes
Once you have committed your changes, you will want to
push your commits (basically, publish
your changes to GitHub). To do so, run:If there are changes made to the This will automatically add the changes from
terminal
main
branch of the
express-rate-limit/express-rate-limit
repository, you may wish to merge those
changes into your branch. To do so, run:terminal
main
branch of the
express-rate-limit/express-rate-limit
repository to the current branch. If you
encounter any merge conflicts, follow
this guide
to resolve them.9
Opening a pull request
Once you have pushed your changes to your fork, follow
these instructions
to open a
pull request.
This contributing guide was inspired by the Electron project’s contributing guide.