Skip to content
Open
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/practica-quality-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: practica-quality-check
on:
push:
branches:
- "*"
- '*'
pull_request:
branches: [main]

Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx pretty-quick --staged
16 changes: 15 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
{}
{
"arrowParens": "avoid",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main selling point of Prettier is "Put aside your personal opinion, avoid team arguments, just use the industry standards that we've set". Should we really adjust its defaults?

"bracketSpacing": true,
"endOfLine": "lf",
"bracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"copy-templates": "rsync -av --exclude '*node_modules*' ./src/code-templates/ ./.dist/src/code-templates",
"build:watch": "tsc --watch",
"start:cli": "node ./.dist/bin/cli.js interactive",
"publish:build": "npm run build && npm publish ./.dist --access public"
"publish:build": "npm run build && npm publish ./.dist --access public",
"prepare": "husky install"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -66,6 +67,7 @@
"@types/prettier": "^2.4.4",
"@types/sinon": "^10.0.11",
"execa": "^5.1.1",
"husky": "^8.0.0",
"jest": "^27.5.1",
"jest-watch-suspend": "^1.1.2",
"jest-watch-typeahead": "^1.1.0",
Expand Down
16 changes: 8 additions & 8 deletions src/code-templates/libraries/logger/definition.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export type LOG_LEVELS = 'debug' | 'info' | 'warn' | 'error' | 'critical';
export type LOG_LEVELS = 'debug' | 'info' | 'warn' | 'error' | 'critical'

export interface Logger {
info(message: string, ...args: any[]): void;
info(message: string, ...args: any[]): void

error(message: string, ...args: any[]): void;
error(message: string, ...args: any[]): void

debug(message: string, ...args: any[]): void;
debug(message: string, ...args: any[]): void

warning(message: string, ...args: any[]): void;
warning(message: string, ...args: any[]): void
}

export interface LoggerConfiguration{
level: LOG_LEVELS;
prettyPrint: boolean;
export interface LoggerConfiguration {
level: LOG_LEVELS
prettyPrint: boolean
}
16 changes: 8 additions & 8 deletions src/code-templates/libraries/logger/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ module.exports = {
// collectCoverageFrom: undefined,

// The directory where Jest should output its coverage files
coverageDirectory: "coverage",
coverageDirectory: 'coverage',

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
coverageProvider: 'v8',

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
Expand Down Expand Up @@ -90,7 +90,7 @@ module.exports = {
notify: true,

// An enum that specifies notification mode. Requires { notify: true }
notifyMode: "change",
notifyMode: 'change',

// A preset that is used as a base for Jest's configuration
//preset: "ts-jest",
Expand Down Expand Up @@ -137,7 +137,7 @@ module.exports = {
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: "node",
testEnvironment: 'node',

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
Expand All @@ -146,10 +146,10 @@ module.exports = {
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
testMatch: ["**/*.test.ts"],
testMatch: ['**/*.test.ts'],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: ["/node_modules/"],
testPathIgnorePatterns: ['/node_modules/'],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
Expand All @@ -167,7 +167,7 @@ module.exports = {
// timers: "real",

// A map from regular expressions to paths to transformers
transform: { "^.+\\.(t|j)s$": "ts-jest" },
transform: { '^.+\\.(t|j)s$': 'ts-jest' },

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
Expand All @@ -186,4 +186,4 @@ module.exports = {

// Whether to use watchman for file crawling
// watchman: true,
};
}
48 changes: 24 additions & 24 deletions src/code-templates/services/order-service/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,56 @@

export default {
port: {
doc: "The API listening port. By default is 0 (ephemeral) which serves as a dynamic port for testing purposes. For production use, a specific port must be assigned",
format: "Number",
doc: 'The API listening port. By default is 0 (ephemeral) which serves as a dynamic port for testing purposes. For production use, a specific port must be assigned',
format: 'Number',
default: 0,
nullable: true,
env: "PORT",
env: 'PORT',
},
logger: {
level: {
doc: "Which type of logger entries should actually be written to the target medium (e.g., stdout)",
format: ["debug", "info", "warn", "error", "critical"],
default: "info",
doc: 'Which type of logger entries should actually be written to the target medium (e.g., stdout)',
format: ['debug', 'info', 'warn', 'error', 'critical'],
default: 'info',
nullable: false,
env: "LOGGER_LEVEL",
env: 'LOGGER_LEVEL',
},
prettyPrint: {
doc: "Weather the logger should be configured to pretty print the output",
doc: 'Weather the logger should be configured to pretty print the output',
format: 'Boolean',
default: true,
nullable: false,
env: "PRETTY_PRINT_LOG",
env: 'PRETTY_PRINT_LOG',
},
destination: {
doc: "destination in which the logger should be written, empty value will be considered as stdout",
doc: 'destination in which the logger should be written, empty value will be considered as stdout',
format: '*',
default: null,
nullable: true,
env: "LOGGER_DEST",
}
env: 'LOGGER_DEST',
},
},
DB: {
userName: {
doc: "The DB connection user name",
format: "String",
default: "myuser",
doc: 'The DB connection user name',
format: 'String',
default: 'myuser',
nullable: false,
env: "DB_USERNAME",
env: 'DB_USERNAME',
},
password: {
doc: "The DB connection password. Don't put production code here",
format: "String",
default: "myuserpassword",
format: 'String',
default: 'myuserpassword',
nullable: false,
env: "DB_PASSWORD",
env: 'DB_PASSWORD',
},
dbName: {
doc: "The default database name",
format: "String",
default: "shop",
doc: 'The default database name',
format: 'String',
default: 'shop',
nullable: false,
env: "DB_NAME",
env: 'DB_NAME',
},
},
};
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("Orders", {
await queryInterface.createTable('Orders', {
id: {
allowNull: false,
autoIncrement: true,
Expand Down Expand Up @@ -32,9 +32,9 @@ module.exports = {
allowNull: false,
type: Sequelize.DATE,
},
});
})

await queryInterface.createTable("Countries", {
await queryInterface.createTable('Countries', {
id: {
allowNull: false,
autoIncrement: true,
Expand All @@ -44,8 +44,8 @@ module.exports = {
name: {
type: Sequelize.STRING,
},
});
})
},

down: (queryInterface, Sequelize) => queryInterface.dropTable("Orders"),
};
down: (queryInterface, Sequelize) => queryInterface.dropTable('Orders'),
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ module.exports = {
up: async (queryInterface, Sequelize) => {
// ✅ Best Practice: Seed only metadata and not test record, read "Dealing with data" section for further information
await queryInterface.bulkInsert(
"Countries",
'Countries',
[
{
name: "Italy",
name: 'Italy',
},
{
name: "USA",
name: 'USA',
},
{
name: "India",
name: 'India',
},
],
{}
);
)
},
down: (queryInterface, Sequelize) => {},
};
}