Skip to content

Instantly share code, notes, and snippets.

View brandonroberts's full-sized avatar

Brandon Roberts brandonroberts

View GitHub Profile
@brandonroberts
brandonroberts / selectors.ts
Created November 17, 2021 13:56
Create Feature 3 - NgRx 13
// books.selectors.ts
import { createSelector } from "@ngrx/store";
import { booksFeature } from "./books.reducer";
export const selectBookListPageViewModel = createSelector(
booksFeature.selectBooks,
booksFeature.selectLoading,
(books, loading) => ({ books, loading })
);
@brandonroberts
brandonroberts / reducer.ts
Created November 17, 2021 13:55
Create Feature 2 - NgRx 13
// `createFeature` is imported from `@ngrx/store`
import { createFeature, createReducer } from "@ngrx/store";
import * as BookListPageActions from "./book-list-page.actions";
import * as BooksApiActions from "./books-api.actions";
interface State {
books: Book[];
loading: boolean;
}
@brandonroberts
brandonroberts / reducer.ts
Created November 17, 2021 13:55
Create Feature 1 - NgRx 13
// books.reducer.ts
import { createReducer } from "@ngrx/store";
import * as BookListPageActions from "./book-list-page.actions";
import * as BooksApiActions from "./books-api.actions";
export const featureName = "books";
export interface State {
books: Book[];
@brandonroberts
brandonroberts / reducer.ts
Created November 17, 2021 13:54
Ivy Reducer - NgRx 13
const myReducer = createReducer(...);
export function reducer(state, action) {
return myReducer(state, action);
}
@brandonroberts
brandonroberts / package.json
Last active August 24, 2021 13:06
Nx 12.8 package.json
{
"name": "myorg",
"scripts": {
"start": "nx serve",
"build": "nx build",
"test": "nx test"
},
"dependencies": {
...
},
@brandonroberts
brandonroberts / main.js
Created August 23, 2021 14:06
Nx 12.8 NestJS Compiled
class MyDto {
static _OPENAPI_METADATA_FACTORY() {
return {
id: { required: true, type: () => String },
count: { required: true, type: () => Number }
};
}
}
exports.MyDto = MyDto;
@brandonroberts
brandonroberts / workspace.json.diff
Created August 23, 2021 14:04
Nx 12.8 NestJS Swagger
"targets": {
"build": {
"executor": "@nrwl/node:build",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/my-server",
"main": "apps/my-server/src/main.ts",
"tsConfig": "apps/my-server/tsconfig.app.json",
"assets": ["apps/my-server/src/assets"],
+ "tsPlugins": ["@nestjs/swagger/plugin"]
@brandonroberts
brandonroberts / my.dto.ts
Created August 23, 2021 14:02
Nx 12.8 NestJS Swagger DTO
export class MyDto {
id: string;
count: number;
}
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ngv12": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
@brandonroberts
brandonroberts / jest.config.js.diff
Last active July 22, 2021 17:20
Jest Config w/helper
+ const { getJestProjects } = require('@nrwl/jest');
+ module.exports = { projects: getJestProjects() };
- module.exports = {
- projects: [
- '<rootDir>/apps/products',
- '<rootDir>/apps/cart',
- '<rootDir>/libs/shared/product/ui',
- '<rootDir>/libs/products/home-page',
- '<rootDir>/libs/cart/cart-page',