generated from SoftwareBrothers/adminjs-feature-template
-
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.
feat: add support for themes in AdminJS (#6)
* chore: draft dark theme * chore: introduced example app * chore: draft wide theme * chore: introduced esm to example app * chore: introduced esm * chore: introduced esm * chore(deps): update deps * chore(deps): update deps * chore: add bundled themes to example app * chore: added root to bundle options * chore: added cli commands, refactored themes structures * ci: with node 18 * chore: cleaned up package json * chore: configured semantic release * chore: configured cli in scripts * chore: use babel to build themes * chore: use babel to build themes * chore: wip * chore: removed css from lint * chore: add theme id to bundler * chore: improved cli documentations * chore: fixed types import in generated themes * chore: cleaned up themes * chore: bump core and design version * chore: add CI configuration * chore: added current theme label in example app * chore: update README * chore: added light theme draft * chore: export light theme * chore: renamed wide theme export * chore: bump adminjs packages * chore: add @adminjs/themes in example app * fix: fixed bundle themes script * chore: removed styled-components from babel * fix: add ignore themes dir when build * chore: improved top bar nested navigation * chore: improved top bar nested navigation * chore: restored no strict config * style: improved generated files format * fix(beta): cleaned up dependencies * fix(beta): fix typescript types building * fix(beta): fixed dark style for phone input * chore: update adminjs to version 7 --------- Co-authored-by: Rafal Dziegielewski <[email protected]>
- Loading branch information
1 parent
3d548e9
commit e664aa6
Showing
88 changed files
with
11,003 additions
and
7,453 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,18 @@ | ||
{ | ||
"plugins": [], | ||
"presets": [ | ||
"@babel/preset-react", | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": "18" | ||
}, | ||
"loose": true, | ||
"modules": false | ||
} | ||
], | ||
"@babel/preset-typescript" | ||
], | ||
"ignore": ["./src/themes/**/*.bundle.js"] | ||
} |
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,23 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint/eslint-plugin"], | ||
"extends": ["plugin:@typescript-eslint/recommended"], | ||
"parserOptions": { | ||
"ecmaVersion": 2020, | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
"jsx": true | ||
} | ||
}, | ||
"rules": { | ||
"react/prop-types": "off", | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
"@typescript-eslint/no-empty-function": "off" | ||
}, | ||
"ignorePatterns": ["node_modules", "dist", "*.css", "example"], | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn commitlint --edit $1 |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint-staged |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint |
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 @@ | ||
{ | ||
"**/*.{js,jsx,ts,tsx}": [ | ||
"yarn format", | ||
"yarn lint:fix" | ||
] | ||
} |
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
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 @@ | ||
**/theme.bundle.js |
File renamed without changes.
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
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
File renamed without changes.
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,21 @@ | ||
{ | ||
"env": { | ||
"es6": true, | ||
"jest": true, | ||
"node": true | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "tsconfig.json", | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
"jsx": true | ||
} | ||
}, | ||
"plugins": ["@typescript-eslint", "react", "prettier"], | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
} | ||
} |
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,17 @@ | ||
version: '3.7' | ||
|
||
services: | ||
adminjs_themes: | ||
container_name: adminjs-themes | ||
image: postgres:15 | ||
environment: | ||
- POSTGRES_DB=adminjs | ||
- POSTGRES_USER=adminjs | ||
- POSTGRES_PASSWORD=adminjs | ||
ports: | ||
- '5432:5432' | ||
volumes: | ||
- adminjs_themes_db:/var/lib/postgresql/data | ||
|
||
volumes: | ||
adminjs_themes_db: |
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,7 @@ | ||
{ | ||
"verbose": false, | ||
"ignore": ["*.test.*", "*.spec.*"], | ||
"exec": "node --loader ts-node/esm src/server.ts", | ||
"watch": ["src"], | ||
"ext": "ts" | ||
} |
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,45 @@ | ||
{ | ||
"name": "adminjs-themes-example", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"license": "MIT", | ||
"scripts": { | ||
"start": "ts-node-esm src/server", | ||
"dev": "nodemon", | ||
"build": "tsc", | ||
"lint": "eslint src --ext ts", | ||
"docker:up": "docker-compose -f docker-compose.yml up -d" | ||
}, | ||
"dependencies": { | ||
"@adminjs/design-system": "^4.0.0-beta-v4.7", | ||
"@adminjs/express": "^6.0.0-beta.3", | ||
"@adminjs/passwords": "^4.0.0-beta.1", | ||
"@adminjs/themes": "^1.0.0-beta.1", | ||
"@adminjs/typeorm": "^5.0.0-beta.1", | ||
"adminjs": "^7.0.0-beta-v7.4", | ||
"argon2": "^0.30.3", | ||
"class-transformer": "^0.5.1", | ||
"class-validator": "^0.14.0", | ||
"connect-pg-simple": "^8.0.0", | ||
"cors": "^2.8.5", | ||
"dotenv": "^16.0.3", | ||
"express": "^4.18.2", | ||
"express-formidable": "^1.2.0", | ||
"express-session": "^1.17.3", | ||
"nodemon": "^2.0.22", | ||
"pg": "^8.10.0", | ||
"reflect-metadata": "^0.1.13", | ||
"tslib": "^2.5.0", | ||
"typeorm": "^0.3.12" | ||
}, | ||
"devDependencies": { | ||
"@types/connect-pg-simple": "^7.0.0", | ||
"@types/cors": "^2.8.13", | ||
"@types/express": "^4.17.17", | ||
"@types/express-session": "^1.17.7", | ||
"@types/node": "^18.15.11", | ||
"dotenv-cli": "^7.1.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.0.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,35 @@ | ||
import argon from 'argon2'; | ||
import PostgresSession from 'connect-pg-simple'; | ||
import session from 'express-session'; | ||
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions.js'; | ||
|
||
import databaseConfig from '../db/config.js'; | ||
import { UserService } from '../modules/user/index.js'; | ||
|
||
const PostgresStore = PostgresSession(session); | ||
|
||
export const sessionStore = new PostgresStore({ | ||
conObject: { | ||
connectionString: (databaseConfig as PostgresConnectionOptions).url, | ||
ssl: (databaseConfig as PostgresConnectionOptions).extra?.ssl, | ||
}, | ||
tableName: 'sessions', | ||
createTableIfMissing: true, | ||
}); | ||
|
||
export const authenticate = async (email: string, password: string) => { | ||
const userService = new UserService(); | ||
const user = await userService.findUserByEmail(email); | ||
|
||
if (user && (await argon.verify(user.password, password))) { | ||
return { | ||
id: user.id, | ||
email: user.email, | ||
role: user.role, | ||
createdAt: user.createdAt, | ||
theme: user.theme, | ||
}; | ||
} | ||
|
||
return null; | ||
}; |
Oops, something went wrong.