Skip to content

Instantly share code, notes, and snippets.

View brunokrebs's full-sized avatar

Bruno brunokrebs

  • Brazil
View GitHub Profile
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { AuthHttp } from 'angular2-jwt';
@Injectable()
export class TaskListService {
private static TASKS_ENDPOINT =
'https://wt-e1870b8a73b27cdee73c468b8c8e3bc4-0.run.webtask.io/tasks';
constructor(private authHttp: AuthHttp) { }
# creates the main component that lists tasks
ng g component task-list
# creates a component to hold a form to add tasks
ng g component task-list/task-form
# creates a service to handle all interaction with our REST API
ng g service task-list/task-list
wt create webtask/tasks.js \
--meta wt-compiler=webtask-tools/express \
-s AUTH0_SECRET=secret-from-auth0.com \
-s MONGO_USER=task-list-user \
-s MONGO_PASSWORD=111222 \
-s MONGO_URL=ds147069.mlab.com:47069/task-list \
--prod
# install Webtask CLI tool
npm install wt-cli -g
# initialize it with our email address
wt init [email protected]
'use strict';
// imports node modules
const express = require('express');
const mongojs = require('mongojs');
const bodyParser = require('body-parser');
const jwt = require('jsonwebtoken');
// creates Express app with JSON body parser
const app = new express();
app.use(bodyParser.json());
.app-container {
padding: 20px;
}
<app-nav-bar></app-nav-bar>
<div class="app-container">
<md-card *ngIf="!authService.authenticated()">
<md-card-title>Hello, visitor.</md-card-title>
<md-card-subtitle>
Please <a (click)="authService.signIn()">sign in</a> to manage your task list.
</md-card-subtitle>
</md-card>
</div>
import { Component } from '@angular/core';
import { AuthService } from './auth.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor(private authService: AuthService) { }
@import '~@angular/material/core/theming/prebuilt/indigo-pink.css';
body {
margin: 0;
}
<app-nav-bar></app-nav-bar>