Skip to content

Instantly share code, notes, and snippets.

View JoscelynJames's full-sized avatar

Joscelyn James JoscelynJames

View GitHub Profile
@JoscelynJames
JoscelynJames / list.pipe.ts
Last active August 8, 2020 02:36
Example of and Angular pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'list', pure: true})
export class ListPipe implements PipeTransform {
transform(value: string[]): string {
return value.join(', ');
}
}
@JoscelynJames
JoscelynJames / shopping-cart.module.ts
Last active July 26, 2020 21:23
Example Feature Module
import { NgModule } from '@angular/core';
import { SharedModule } from '../shared.module.ts';
import { ShoppingCartComponent } from './shopping-cart.component';
import { ShoppingItemComponent } from './shopping-item.component';
@NgModule({
declarations: [
ShoppingCartComponent, // Notice this component is also being exported below
@JoscelynJames
JoscelynJames / gist:5c4e3f8535f3022b7b208f4373ee9b16
Last active July 26, 2020 16:23
Basic Angular Core Module
@NgModule({
providers: [
ChartService,
CovidService,
],
})
export class CoreModule { }
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
BrowserAnimationsModule,
CoreModule,
],
exports: [CoreModule],
bootstrap: [AppComponent]
})
@JoscelynJames
JoscelynJames / S3-Static-Sites.md
Created July 8, 2018 16:55 — forked from bradwestfall/S3-Static-Sites.md
Use S3 and CloudFront to host Static Single Page Apps (SPAs) with HTTPs and www-redirects. Also covers deployments.

S3 Static Sites

What this will cover

  • Host a static website at S3
  • Redirect www.website.com to website.com
  • Website can be an SPA (requiring all requests to return index.html)
  • Free AWS SSL certs
  • Deployment with CDN invalidation

Resources

@JoscelynJames
JoscelynJames / express-server-template
Created October 24, 2017 16:55
npm install express cors body-parser morgan
const http = require('http')
const express = require('express')
const bodyParser = require('body-parser')
const morgan = require('morgan')
const cors = require('cors')
const app = module.exports = express()
const server = http.createServer(app)
const port = parseInt(process.env.PORT || 3000)
app.use(bodyParser.json())
const router = module.exports = require('express').Router();
router.get('/', teas});
router.get('/:id', getOneTea});
router.put('/:id', editTea});
router.post('/', addTea});
router.del('/:id', deleteTea});
function teas(req, res) {
res.json({ data: teas });