Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
version: 10
- name: Install dependencies
run: HUSKY=0 pnpm install --frozen-lockfile # Skip Husky, install from frozen lockfile
run: pnpm install --frozen-lockfile # Install from frozen lockfile
- name: Format files
run: pnpm run format
- name: Check for changes
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ jobs:
with:
version: 10
- name: Install dependencies
run: HUSKY=0 pnpm install --frozen-lockfile # Skip Husky, install from frozen lockfile
run: pnpm install --frozen-lockfile # Install from frozen lockfile
- name: Lint files
run: pnpm lint
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
version: 10
- name: Install dependencies
run: HUSKY=0 pnpm install --frozen-lockfile # Skip Husky, install from frozen lockfile
run: pnpm install --frozen-lockfile # Install from frozen lockfile
- name: Release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
version: 10

- name: Install dependencies
run: HUSKY=0 pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile # Install from frozen lockfile

- name: Run tests
run: pnpm test
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
todos.md
.vscode/
.vscode
.astro
.docusaurus
build/
app/scripts/*.json

# Logs
logs
*.log

# Test files (prevent Biome formatting)
test/
coverage/
tests/
spec/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down
1 change: 0 additions & 1 deletion .husky/commit-msg

This file was deleted.

1 change: 0 additions & 1 deletion .husky/pre-commit

This file was deleted.

10 changes: 10 additions & 0 deletions .releaserc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
branches: ['main'],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/npm',
'@semantic-release/git',
'@semantic-release/github',
],
};
61 changes: 36 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@
>
> All dinosaur images are sourced from Wikimedia Commons and are licensed under various licenses - each with their own specific license terms and are attributed accordingly.
>
> By using this API, you agree to properly attribute the sources and comply with their respective licenses.
> By using this API, you agree to properly attribute the sources and comply with their respective licenses. Please see the [Terms of Use](https://vikiru.github.io/restasaurus/getting-started/terms/).
>
> Examples can be seen below in [Attribution Examples](#-attribution-examples).

For a better understanding of the information provided by the API, please check out the [models](./app/models) directory. The schemas used within the MongoDB database include:

> - [**Dinosaur**](https://github.com/vikiru/restasaurus/blob/main/app/models/Dinosaur.js): This is the main model which represents a dinosaur, including its unique properties such as name, temporal range, diet, locomotion type, and a description. Additionally, it also contains references to the sub-models below, which are populated with their relevant values when handling API requests.
> - [**ClassificationInfo**](./app/models/ClassificationInfo.js): This model contains the classification information of a dinosaur, including details like its family, order, and genus.
> - [**ClassificationInfo**](./app/models/ClassificationInfo.js): This model contains the classification information of a dinosaur, including details like its family, order, and genus. Read more about the taxonomy represented by this model [here](https://vikiru.github.io/restasaurus/getting-started/taxonomy/).
> - [**DinosaurImage**](https://github.com/vikiru/restasaurus/blob/main/app/models/DinosaurImage.js): This model is used to store the image data related to a dinosaur, including the image source and attribution details.
> - [**DinosaurSource**](https://github.com/vikiru/restasaurus/blob/main/app/models/DinosaurSource.js): This model represents the source of the dinosaur data, which is the Wikipedia article for that particular dinosaur. This includes information such as the title, author, last revision date, revision history url, and more.

Expand Down Expand Up @@ -212,11 +212,11 @@ Testing:

Documentation:

- Docs are built using [Docusaurus](https://docusaurus.io/)
- OpenAPI Specification converted to `.md` using: [Redocusaurus](https://github.com/rohit-gohri/redocusaurus)
- Search functionality provided by: [docusaurus-lunr-search](https://github.com/praveenn77/docusaurus-lunr-search)
- Analytics using [Google Analytics](https://marketingplatform.google.com/about/analytics/)
- Documentation site hosted via [GitHub Pages](https://pages.github.com/)
- Docs are built using [Starlight](https://starlight.astro.build/) by [Astro](https://astro.build/)
- Link validation: [starlight-links-validator](https://github.com/HiDeoo/starlight-links-validator)
- Theme: [starlight-theme-rapide](https://github.com/HiDeoo/starlight-theme-rapide)
- OpenAPI integration: [starlight-openapi](https://github.com/HiDeoo/starlight-openapi)
- Documentation site hosted via [GitHub Pages](https://docs.github.com/en/pages)

REST API

Expand All @@ -231,6 +231,7 @@ CI:
Dev Tools:

- [Biome](https://biomejs.dev/)
- [Knip](https://github.com/webpro-nl/knip)
- [WakaTime](https://wakatime.com/)
- [MongoDB Compass](https://www.mongodb.com/products/tools/compass)
- [Postman](https://www.postman.com/)
Expand Down Expand Up @@ -393,30 +394,40 @@ pnpm postData
pnpm make-badges
```

9. Prepare Git Hooks via [Husky](https://typicode.github.io/husky/).
9. Prepare Git Hooks via [Lefthook](https://github.com/evilmartians/lefthook).

```bash
pnpm prepare
pnpm postinstall
```

10. Check for unused code and dependencies with [Knip](https://github.com/webpro-nl/knip).

```bash
pnpm unused
```

## ✨ Acknowledgments

- [Docusaurus](https://docusaurus.io/)
- [Redocusaurus](https://github.com/rohit-gohri/redocusaurus)
- [GitHub Pages](https://pages.github.com/)
- [Swagger Editor](https://swagger.io/tools/swagger-editor/)
- [Swagger Documentation](https://swagger.io/specification/)
- [Chai Documentation](https://www.chaijs.com/)
- [Express Documentation](https://expressjs.com/en/4x/api.html)
- [Mocha Documentation](https://mochajs.org/)
- [MongoDB Documentation](https://www.mongodb.com/docs/)
- [Mongoose Documentation](https://mongoosejs.com/docs/)
- [Sinon Documentation](https://sinonjs.org/releases/latest/)
- [Shields Badges](https://github.com/badges/shields)
- [regex101](https://regex101.com/)
- [Favicon Generator](https://favicon.io/favicon-generator/)
- [node-html-parser](https://github.com/taoqf/node-html-parser)
- [Semantic Release](https://github.com/semantic-release/semantic-release)
- [Starlight](https://starlight.astro.build/)
- [Astro](https://astro.build/)
- [starlight-links-validator](https://github.com/HiDeoo/starlight-links-validator)
- [starlight-theme-rapide](https://github.com/HiDeoo/starlight-theme-rapide)
- [starlight-openapi](https://github.com/HiDeoo/starlight-openapi)
- [Docusaurus](https://docusaurus.io/)
- [Redocusaurus](https://github.com/rohit-gohri/redocusaurus)
- [GitHub Pages](https://pages.github.com/)
- [Swagger Editor](https://swagger.io/tools/swagger-editor/)
- [Swagger Documentation](https://swagger.io/specification/)
- [Chai Documentation](https://www.chaijs.com/)
- [Express Documentation](https://expressjs.com/en/4x/api.html)
- [Mocha Documentation](https://mochajs.org/)
- [MongoDB Documentation](https://www.mongodb.com/docs/)
- [Mongoose Documentation](https://mongoosejs.com/docs/)
- [Sinon Documentation](https://github.com/sinonjs/sinon)
- [Shields Badges](https://github.com/badges/shields)
- [regex101](https://regex101.com/)
- [Favicon Generator](https://favicon.io/favicon-generator/)
- [node-html-parser](https://github.com/taoqf/node-html-parser)

Additionally, this API would not be possible without the dinosaur information and image information retrieved from all of the [Wikipedia](https://en.wikipedia.org/wiki/Main_Page) articles accessed through the [Wikipedia API](https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page). All images and text provided by this API belong to their respective authors.

Expand Down
16 changes: 9 additions & 7 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
"$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
"assist": {
"actions": {
"source": {
Expand All @@ -25,12 +25,14 @@
"*.config.ts",
"*.config.js",
"!/**/node_modules",
"!/**/dist",
"!/**/build",
"!/**/public",
"!/**/out",
"!/**/.git",
"!/**/.github",
"!/test/**/*.test.js",
"!/test/**/*.test.ts",
"!/dist",
"!/build",
"!/public",
"!/out",
"!/.git",
"!/.github",
"!/**/*.css",
"!/**/*.html",
"!/**/*.json",
Expand Down
3 changes: 1 addition & 2 deletions commitlint.config.js → commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module.exports = {
export default {
extends: ['@commitlint/config-conventional'],
rules: {
'body-max-line-length': [0],

'footer-max-line-length': [0],
},
};
17 changes: 17 additions & 0 deletions knip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"project": [
"tsconfig.json"
],
"entry": [
"app/**/*.{js,mjs,cjs,ts}",
"*.{js,mjs,cjs,ts}"
],
"ignoreExportsUsedInFile": {
"interface": true,
"type": true
},
"tags": [
"-lintignore"
]
}
52 changes: 52 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# EXAMPLE USAGE:
#
# Refer for explanation to following link:
# https://lefthook.dev/configuration/
#
pre-commit:
jobs:
- name: Lint files with Biome.js
glob: "*.{js,mjs,cjs,ts,jsx,tsx}"
run: pnpm lint --colors=off {staged_files}

commit-msg:
jobs:
- name: Validate commit-msg with commitlint
run: pnpm exec commitlint --edit $1
# pre-push:
# jobs:
# - name: packages audit
# tags:
# - frontend
# - security
# run: yarn audit
#
# - name: gems audit
# tags:
# - backend
# - security
# run: bundle audit
#
# pre-commit:
# parallel: true
# jobs:
# - run: yarn eslint {staged_files}
# glob: "*.{js,ts,jsx,tsx}"
#
# - name: rubocop
# glob: "*.rb"
# exclude:
# - config/application.rb
# - config/routes.rb
# run: bundle exec rubocop --force-exclusion {all_files}
#
# - name: govet
# files: git ls-files -m
# glob: "*.go"
# run: go vet {files}
#
# - script: "hello.js"
# runner: node
#
# - script: "hello.go"
# runner: go run
36 changes: 15 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
"retrieveData": "node ./app/scripts/constructDinoNames.js && node ./app/scripts/retrieveData.js",
"postData": "node ./app/scripts/postData.js",
"make-badges": "istanbul-badges-readme",
"prepare": "husky"
"postinstall": "lefthook install",
"unused": "knip"
},
"dependencies": {
"@mongodb-js/zstd": "^1.2.2",
"@mongodb-js/zstd": "^7.0.0",
"body-parser": "^1.20.3",
"compression": "^1.8.1",
"cors": "^2.8.5",
Expand All @@ -40,7 +41,7 @@
"express-rate-limit": "^7.5.1",
"express-validator": "^7.3.1",
"helmet": "^7.2.0",
"mongodb": "^6.21.0",
"mongodb": "^7.0.0",
"mongoose": "^8.20.1",
"mongoose-autopopulate": "^1.2.1",
"mongoose-hidden": "^1.9.1",
Expand All @@ -53,35 +54,28 @@
"winston": "^3.18.3"
},
"devDependencies": {
"@biomejs/biome": "2.3.8",
"@biomejs/biome": "^2.3.11",
"@commitlint/cli": "^20.1.0",
"@commitlint/config-conventional": "^20.0.0",
"@semantic-release/git": "^10.0.1",
"chai": "^4.5.0",
"chai-http": "^4.4.0",
"chai": "^6.2.2",
"chai-http": "^5.1.2",
"cross-env": "^5.2.1",
"esm": "^3.2.25",
"husky": "^9.1.7",
"istanbul-badges-readme": "^1.9.0",
"mocha": "^10.8.2",
"knip": "^5.80.2",
"lefthook": "^2.0.15",
"mocha": "^11.7.5",
"nodemon": "^3.1.11",
"nyc": "^15.1.0",
"open-cli": "^8.0.0",
"proxyquire": "^2.1.3",
"semantic-release": "^25.0.2",
"sinon": "^17.0.1"
},
"release": {
"branches": [
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/git",
"@semantic-release/github"
]
"sinon": "^21.0.1",
"tsx": "^4.21.0",
"typescript": "^5.9.3",
"vitest": "^4.0.17"
},
"ignorePatterns": [
"./node_modules/**",
Expand All @@ -90,4 +84,4 @@
"engines": {
"node": ">=16.9"
}
}
}
Loading