Skip to content

Commit

Permalink
First version of auth handler library (#1)
Browse files Browse the repository at this point in the history
* First version of auth handler library

* update workflows

* Readme cleanup from merge
  • Loading branch information
mattdean-digicatapult authored May 13, 2024
1 parent 7c4589b commit 3da47d1
Show file tree
Hide file tree
Showing 29 changed files with 8,781 additions and 1 deletion.
1 change: 1 addition & 0 deletions .depcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignores: ['prettier-plugin-organize-imports', 'tsimp']
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Github CODEOWNERS file

# Global code-owners for this repository
* @digicatapult/software-engineering
46 changes: 46 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: Bug report
about: Create a report to help us improve
---

<!--
Have you read our Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/digicatapult/tsoa-oauth-express/.github/blob/main/CODE_OF_CONDUCT.md
-->

### Prerequisites

- [ ] Put an X between the brackets on this line if you have done all of the following:
- Checked the FAQs for common solutions: <https://github.com/digicatapult/tsoa-oauth-express/blob/main/CONTRIBUTING.md/#FAQs>
- Checked that your issue isn't already filed: <https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Atsoa-oauth-express>

### Description

<!-- Description of the issue -->

### Steps to Reproduce

1. <!-- First Step -->
2. <!-- Second Step -->
3. <!-- and so on… -->

**Expected behaviour:**

<!-- What you expect to happen -->

**Actual behaviour:**

<!-- What actually happens -->

**Reproduces how often:**

<!-- What percentage of the time does it reproduce? -->

### Versions

<!-- You can get this information from copy and pasting the version on the home page or via package.json. Also, please include the OS and what version of the OS you're running. -->

### Additional Information

<!-- Any additional information, configuration or data that might be necessary to reproduce the issue. -->
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Feature request
about: Suggest an idea for this project
---

<!--
Have you read our Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/digicatapult/tsoa-oauth-express/.github/blob/main/CODE_OF_CONDUCT.md
---
Also note that the Digital Catapult team has finite resources so it's unlikely that we'll work on feature requests. If we're interested in a particular feature however, we'll follow up and ask you to submit an RFC to talk about it in more detail.
-->

## Summary

<!-- One paragraph explanation of the feature. -->

## Motivation

<!-- Why are we doing this? What use cases does it support? What is the expected outcome? -->

## Describe alternatives you've considered

<!-- A clear and concise description of the alternative solutions you've considered. Be sure to explain why the existing customisability isn't suitable for this feature. -->

## Additional context

<!-- Add any other context or screenshots about the feature request here. -->
10 changes: 10 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
⚛👋 Hello there! Welcome. Please follow the steps below to tell us about your contribution.

1. Copy the correct template for your contribution

- 🐛 Are you fixing a bug? Copy the template from <https://github.com/digicatapult/tsoa-oauth-express/blob/main/.github/ISSUE_TEMPLATE/bug_report.md>
- 💻 Are you changing functionality? Copy the template from <https://github.com/digicatapult/tsoa-oauth-express/blob/main/.github/ISSUE_TEMPLATE/feature_request.md>

2. Replace this text with the contents of the template
3. Fill in all sections of the template
4. Click "Create pull request"
118 changes: 118 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Release

on:
push:
branches: ["main"]

jobs:

preconditions:
runs-on: ubuntu-latest
outputs:
repo_name: ${{ steps.repo_ids.outputs.REPO_NAME }}
org_name: ${{ steps.repo_ids.outputs.ORG_NAME }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check token
run: |
if [ -z "${{ secrets.GITHUB_TOKEN }}"]; then
echo "Must provide a GITHUB_TOKEN secret in order to run release workflow"
exit 1
fi
- name: Get repository identifiers
id: repo_ids
run: |
REPO_NAME=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
ORG_NAME=$(echo "${{ github.event.repository.owner.name }}" | tr '[:upper:]' '[:lower:]')
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_OUTPUT
echo "ORG_NAME=$ORG_NAME" >> $GITHUB_OUTPUT
static-checks:
name: Run Static Analysis Checks
strategy:
matrix:
command: [lint, depcheck, check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install Packages
run: npm ci
- name: Lint
run: npm run ${{ matrix.command }}

tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install Packages
run: npm ci
- name: Run tests
run: npm run test

check-version:
name: "Check version"
runs-on: ubuntu-latest
outputs:
is_new_version: ${{ steps.get_version.outputs.IS_NEW_VERSION }}
version: ${{ steps.get_version.outputs.VERSION }}
build_date: ${{ steps.get_version.outputs.BUILD_DATE }}
is_prerelease: ${{ steps.get_version.outputs.IS_PRERELEASE }}

steps:
- uses: actions/checkout@v4
- name: Check version
id: get_version
uses: digicatapult/check-version@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

publish-npm:
name: 'Publish package to NPMJS'
needs:
- static-checks
- test
- check-version
runs-on: ubuntu-latest
if: ${{ needs.check-version.outputs.is_new_version == 'true' }}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
scope: '@digicatapult'
- name: Install Packages
run: npm ci
- name: Build
run: npm run build
- name: Publish to npmjs packages
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }}
81 changes: 81 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Lint and Test

on:
push:
branches-ignore: ["main"]

jobs:

repo_ids:
runs-on: ubuntu-latest
outputs:
repo_name: ${{ steps.repo_ids.outputs.REPO_NAME }}
org_name: ${{ steps.repo_ids.outputs.ORG_NAME }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get repository identifiers
id: repo_ids
run: |
REPO_NAME=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
ORG_NAME=$(echo "${{ github.event.repository.owner.name }}" | tr '[:upper:]' '[:lower:]')
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_OUTPUT
echo "ORG_NAME=$ORG_NAME" >> $GITHUB_OUTPUT
static-checks:
name: Run Static Analysis Checks
strategy:
matrix:
command: [lint, depcheck, check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install Packages
run: npm ci
- name: Lint
run: npm run ${{ matrix.command }}

tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install Packages
run: npm ci
- name: Run tests
run: npm run test

check-version:
name: "Check version"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check version
id: get_version
uses: digicatapult/check-version@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.tsimp
build
node_modules
example/routes.ts
example/swagger.json
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"singleQuote": true,
"semi": false,
"trailingComma": "es5",
"printWidth": 120,
"plugins": [
"prettier-plugin-organize-imports"
]
}
46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project, and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expressions, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behaviour that contributes to creating a positive environment include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behaviour by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behaviour and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behaviour.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behaviour may be reported by contacting the project team at [[email protected]](mailto:[email protected]?subject=tsoa-oauth-express). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team's obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct has been adapted from the [Contributor Covenant][homepage], version 1.4, available at [https://contributor-covenant.org/version/1/4][version]

[homepage]: https://contributor-covenant.org
[version]: https://contributor-covenant.org/version/1/4/
Loading

0 comments on commit 3da47d1

Please sign in to comment.