This repository has been archived by the owner on Dec 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
4,825 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.yml] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ["@anolilab/eslint-config"], | ||
parserOptions: { | ||
project: "./tsconfig.eslint.json", | ||
tsconfigRootDir: __dirname, | ||
projectFolderIgnoreList: [".blitz/**"], | ||
}, | ||
env: { | ||
// Your environments (which contains several predefined global variables) | ||
browser: true, | ||
node: true, | ||
commonjs: true, | ||
es6: true, | ||
// mocha: true, | ||
jest: true, | ||
// jquery: true | ||
}, | ||
globals: { | ||
// Your global variables (setting to false means it's not allowed to be reassigned) | ||
// | ||
// myGlobal: false | ||
}, | ||
rules: { | ||
// Customize your rules | ||
"unicorn/no-array-for-each": "off", | ||
"unicorn/no-null": "off", | ||
"unicorn/no-array-reduce": "off", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
12.20.1 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"semi": true, | ||
"singleQuote": false, | ||
"quoteProps": "as-needed", | ||
"jsxSingleQuote": false, | ||
"trailingComma": "all", | ||
"bracketSpacing": true, | ||
"jsxBracketSameLine": false, | ||
"arrowParens": "always", | ||
"rangeStart": 0, | ||
"rangeEnd": null, | ||
"requirePragma": false, | ||
"insertPragma": false, | ||
"proseWrap": "preserve", | ||
"htmlWhitespaceSensitivity": "css", | ||
"vueIndentScriptAndStyle": false, | ||
"endOfLine": "lf", | ||
"embeddedLanguageFormatting": "auto" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
import { RecipeBuilder, paths, addImport } from "@blitzjs/installer"; | ||
import { join } from "path"; | ||
import j from "jscodeshift"; | ||
import { Collection } from "jscodeshift/src/Collection"; | ||
|
||
import pkg from "./package.json"; | ||
|
||
export default RecipeBuilder() | ||
.setName("Tailwind UI") | ||
.setOwner(pkg.author) | ||
.setRepoLink(pkg.repository.url) | ||
.addAddDependenciesStep({ | ||
stepId: "addDeps", | ||
stepName: "Add npm dependencies", | ||
explanation: `Swagger requires a couple of dependencies to get up and running.`, | ||
packages: [ | ||
{ name: "swagger-jsdoc", version: "latest" }, | ||
{ name: "swagger-ui-react", version: "latest" }, | ||
{ name: "@types/swagger-jsdoc", version: "latest", isDevDep: true }, | ||
{ name: "@types/swagger-ui-react", version: "latest", isDevDep: true }, | ||
], | ||
}) | ||
.addNewFilesStep({ | ||
stepId: "addIntegrations", | ||
stepName: "Add Swagger helper files", | ||
explanation: `Helper to create spec based on swagger-jsdoc`, | ||
targetDirectory: ".", | ||
templatePath: join(__dirname, "templates", "integrations"), | ||
templateValues: {}, | ||
}) | ||
.addNewFilesStep({ | ||
stepId: "addSwaggerPage", | ||
stepName: "Add Swagger page file", | ||
explanation: `Helper to create spec based on swagger-jsdoc`, | ||
targetDirectory: ".", | ||
templatePath: join(__dirname, "templates", "pages"), | ||
templateValues: {}, | ||
}) | ||
.build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "blitzjs-swagger-recipe", | ||
"version": "1.0.0", | ||
"description": "", | ||
"keywords": [ | ||
"blitzjs", | ||
"swagger", | ||
"react" | ||
], | ||
"homepage": "https://github.com/anolilab/blitzjs-swagger-recipe", | ||
"bugs": { | ||
"url": "https://github.com/anolilab/blitzjs-swagger-recipe/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/anolilab/blitzjs-swagger-recipe.git" | ||
}, | ||
"license": "MIT", | ||
"author": "Daniel Bannert <[email protected]> (https://github.com/prisis)", | ||
"main": "index.ts", | ||
"dependencies": { | ||
"@types/jscodeshift": "0.11.0", | ||
"jscodeshift": "0.12.0" | ||
}, | ||
"devDependencies": { | ||
"@anolilab/eslint-config": "^2.1.1", | ||
"@anolilab/prettier-config": "^2.0.1", | ||
"@types/lodash.merge": "^4.6.6", | ||
"@types/swagger-jsdoc": "^6.0.0", | ||
"@types/swagger-ui-react": "^3.35.1", | ||
"@typescript-eslint/eslint-plugin": "^4.26.1", | ||
"@typescript-eslint/parser": "^4.26.1", | ||
"eslint": "^7.28.0", | ||
"eslint-plugin-jest": "^24.3.6", | ||
"eslint-plugin-react": "^7.24.0", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"lint-staged": "^11.0.0", | ||
"prettier": "^2.3.1", | ||
"prettier-plugin-prisma": "^0.11.1", | ||
"pretty-quick": "^3.1.0", | ||
"typescript": "^4.3.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import merge from "lodash.merge"; | ||
import path from "path"; | ||
import swaggerJsdoc from "swagger-jsdoc"; | ||
|
||
import { SwaggerOptions } from "./types"; | ||
|
||
const API_FOLDERS = [ | ||
"pages/api", | ||
"pages/**/api", | ||
"pages/**/api/**", | ||
]; | ||
|
||
export default function createSwaggerSpec({ | ||
openApiVersion = "3.0.0", apiFolders = API_FOLDERS, title, version, options: swaggerOptions = {}, | ||
}: SwaggerOptions) { | ||
const folders: string[] = []; // files containing annotations as above | ||
|
||
apiFolders?.forEach((folder) => { | ||
const apiDirectory = path.join(process.cwd(), folder); | ||
|
||
folders.push(`${apiDirectory}/*.js`, `${apiDirectory}/*.ts`); | ||
}); | ||
|
||
const options = merge({ | ||
definition: { | ||
openapi: openApiVersion, | ||
info: { | ||
title, | ||
version, | ||
}, | ||
}, | ||
apis: folders, | ||
}, swaggerOptions); | ||
|
||
return swaggerJsdoc(options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import swaggerJSDoc from "swagger-jsdoc"; | ||
|
||
export type SwaggerOptions = { | ||
openApiVersion?: string; | ||
apiFolders?: string[]; | ||
title: string; | ||
version: string; | ||
options?: swaggerJSDoc.Options | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import "swagger-ui-react/swagger-ui.css"; | ||
|
||
import { GetStaticProps, Head, InferGetStaticPropsType } from "blitz"; | ||
import createSwaggerSpec from "integrations/swagger/create-swagger-spec"; | ||
import React from "react"; | ||
import SwaggerUI from "swagger-ui-react"; | ||
|
||
import packages from "../../../package.json"; | ||
|
||
const ApiDocument = ({ spec }: InferGetStaticPropsType<typeof getStaticProps>) => ( | ||
<> | ||
<Head> | ||
<title>{`${packages.name} Swagger`}</title> | ||
<style> | ||
{` | ||
body { | ||
background: #fafafa !important; | ||
} | ||
`} | ||
</style> | ||
</Head> | ||
<SwaggerUI spec={spec} /> | ||
</> | ||
); | ||
|
||
// eslint-disable-next-line unicorn/prevent-abbreviations | ||
export const getStaticProps: GetStaticProps = async () => { | ||
const spec: Record<string, any> = createSwaggerSpec({ | ||
title: `${packages.name} Swagger`, | ||
version: packages.version, | ||
}); | ||
|
||
return { | ||
props: { | ||
spec, | ||
}, | ||
}; | ||
}; | ||
|
||
export default ApiDocument; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// see https://github.com/typescript-eslint/typescript-eslint/issues/890 | ||
{ | ||
"extends": "./tsconfig.json", | ||
"exclude": ["node_modules"], | ||
// "include": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES5", | ||
"module": "commonjs", | ||
"checkJs": true, | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"baseUrl": "./", | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"strictNullChecks": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"noUncheckedIndexedAccess": true, | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve", | ||
"incremental": true, | ||
"tsBuildInfoFile": ".tsbuildinfo", | ||
}, | ||
"exclude": ["node_modules", ".yarn"], | ||
"include": ["**/*.ts", "**/*.tsx"] | ||
} |
Oops, something went wrong.