Skip to content

Instantly share code, notes, and snippets.

View lydemann's full-sized avatar

Christian Lüdemann lydemann

View GitHub Profile
@lydemann
lydemann / server.ts
Created December 28, 2020 18:34
server.ts
const verifyToken = async ({ authorization, schoolid }) => {
if (authorization) {
const newToken = authorization.replace('Bearer ', '');
const header = await admin
.auth()
.verifyIdToken(newToken)
.then(decodedToken => {
if (decodedToken.firebase.tenant !== schoolid) {
throw new AuthenticationError("User doesn't have access to school");
}
@lydemann
lydemann / course.routing.ts
Created October 31, 2020 09:44
course.routing.ts
const routes: Routes = [
{
path: `:${selectedSectionIdRouteParam}`,
canActivate: [AuthGuard],
resolve: [CourseResolver],
component: CourseComponent,
children: [
{
path: `action-items`,
component: ActionItemsComponent,
@lydemann
lydemann / router.selectors.ts
Created October 31, 2020 09:43
router.selectors.ts
import { ActivatedRouteSnapshot } from '@angular/router';
import * as fromRouter from '@ngrx/router-store';
import { createFeatureSelector, createSelector } from '@ngrx/store';
export interface State {
router: fromRouter.RouterReducerState;
}
export const selectRouter = createFeatureSelector<
State,
@lydemann
lydemann / todo-list-sandbox.service.ts
Created June 20, 2020 11:23
todo-list-sandbox.service.ts
public todoListChanged(affectedIds: string[]) {
this.store.dispatch(
TodoListActions.todoListChanged({
affectedIds,
}),
);
}
@lydemann
lydemann / todo-list-sandbox.service.ts
Created June 20, 2020 11:23
todo-list-sandbox.service.ts
public todoListChanged(affectedIds: string[]) {
this.store.dispatch(
TodoListActions.todoListChanged({
affectedIds: []
}),
);
}
@lydemann
lydemann / todo-list-sandbox.service.ts
Created June 20, 2020 11:12
todo-list-sandbox.service.ts
TodoListActions.todoFormSubmited({
todoItem: {
...todoItem,
},
}),
@lydemann
lydemann / todo-list-sandbox.service.ts
Created June 20, 2020 11:09
todo-list-sandbox.service.ts
public loadTodoList() {
this.store.dispatch(TodoListActions.getTodoListRequest());
}
@lydemann
lydemann / todo-list.component.html
Created June 3, 2020 15:32
todo-list.component.html
<app-crud-item
*ngFor="let todo of todos"
[todoItem]="todo"
data-test="todo-item"
(todoDelete)="deleteTodo($event)"
(todoEdit)="selectTodoForEdit($event)"
(todoCompleteToggled)="todoCompleteToggled($event)"
></app-crud-item>
@lydemann
lydemann / todo.po.ts
Last active June 3, 2020 15:33
todo.po.ts
public static checkForTodos() {
cy.get('[data-test=todo-item]').should('have.length', 5);
}
@lydemann
lydemann / todo.spec.ts
Created June 3, 2020 15:25
todo.spec.ts
import { TodoPage } from '../support/todo.po';
describe('TodoList', () => {
beforeEach(() => {
cy.setupAppGlobalRoutes();
TodoPage.goToPage();
});
it('should should show todo items', () => {
TodoPage.checkForTodos();