- Notifications
You must be signed in to change notification settings - Fork14
EreckGordon/angular-universal-pwa-starter
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Angular Universal PWA Starter built with Angular Cli on Nestjs with TypeORM + Postgres. Auth with jsonwebtoken library.
- angular cli
- yarn (dependency management)
- angular 5.0+ (new service worker)
- I have provided public and private keys for demonstration purposes only. Please do not use them in your project.
- don't even check your real keys into source control.
- You have another folder called angular-universal-pwa-starter-deploy on the same level that you have angular-universal-pwa-starter.
- Example deploy repo
- angular-universal-pwa-starter-deploy contains:a git repo, .gitignore, and .gitattributes. You will copy over the needed files with build scripts. It is the deployment folder that you pull from to update the server.
- The various build scripts compile the server and move the dist folder & package.json to the angular-universal-pwa-starter-deploy folder.
- Postgres Config You have a database with the same configuration as linked, or you change that config to database user info of your choosing.
- Change SEO Defaults
- /src/app/app.common.module.ts
{appId: 'angular-universal-pwa-starter'} - /server/modules/database/database.providers.ts set your database
username,password, anddatabasefields. private.keyandpublic.keygenerate your own. Don't store your production keys on github.- dotenv: create a file called
.envin the root of the project (ie next to readme.md). Do not save it to source control. Give it the following variables:SESSION_ID_SECURE_COOKIE=false POSTGRES_PORT=5432 POSTGRES_USERNAME=postgres POSTGRES_PASSWORD=testingpass POSTGRES_DATABASE=testingDB MAILGUN_API_KEY=yourAPIKey MAILGUN_EMAIL_DOMAIN=mail.yourwebsite.com SITENAME_BASE=yourwebsite.com SITE_URL=http://localhost:4200 - create another
.envfile in your deploy folder, it will have the same variable names, but with values suited for a production environment.
- why bother with a depoyment repo? precompile everything on your dev environment, it is probably a beefier machine. A $5 Digital Ocean droplet runs out of memory when trying to run
ng build --prod, so let's just skip that pain entirely.
- 3 terminals:
npm run dev-serverto run the aping serve --aot --env=e2eto run the frontend which protracter will use in watch modenpm run e2e:watche2e tests which rerun upon file save.
ng serve --aot- Run in frontend aot development mode on port 4200.npm run dev-server- Runs server on port 8000 via ts-node, assumes no frontend changes in regards to rendering with universal.npm run prep-dev-server- Full build of frontend, then serves frontend and backend on port 8000 via ts-node.npm run deploy- Build and push server & frontend assets to github deployment repo.npm run analyze-aot- Bundle analysis of non-tree shaken bundle. lets you see the individual angular module pieces.npm run analyze-deploy- Bundle analysis of tree shaken bundle. kind of opaque, but truest to reality.yarn upgrade-interactive- Upgrade only what you want to.npm run format- formats with tsfmt (typescript-formatter) based on tsfmt.json settings. This script gets called automatically beforeprep-dev-serveranddeploy.
npm run deploy- first it runs
formatwhichs reads options from tsfmt.json and formats code for consistent style. - second it runs
prep-front-end- a: it runs
ng build prodto build the frontend production app. - b: it runs
ng build --prod --app 1 --output-hashing=falseto build the server Aot Factory:AppServerModuleNgFactory
- a: it runs
- third it runs
prep-serverwhich uses nestjs.tsconfig.json to compile the server assets to js. - fourth it runs
copy-needed-files-to-deploy-folderwhich copies yarn.lock and package.json for installing dependencies on server and moves the dist folder to angular-universal-pwa-starter-deploy (or whatever you name your folder ending in -deploy) - fifth it runs
deploy-to-githubwhich changes your directory to the deploy folder, then makes an auto generated commit of the contents of the deploy folder.
- first it runs
creating deployment on vps:
cd /var/www/sudo git remote add origin https://github.com/EreckGordon/angular-universal-pwa-starter-deploysudo git pull origin masteryarnupdating deployment:
ssh root@ipv4 addresssu - webcd /var/www/sudo git pull origin masteryarnpm2 restart dist/serverlinting + standardize code formatting<--tsfmtprettiertestingfrontend<-- angular-cli has working tests now.backend<-- e2e is only coverage currently.
configure environment variable for server like cli. This would allow insecure cookies during dev and secure during prod without fiddling by hand.<-- dotenvError: Could not extract user from request: jwt expiredneed to deal with expired JWT.attempt to renew token, if user no longer exists on db flush cookiesrefactor auth-service so it isn't just one large file.
frontend auth moduleobservable auth serviceguardsrequest password resetcomponentserver functionality
password resetcomponentserver functionality
account management componentdelete user modalchange password inline (*ngIf)
logout componentinform user of errors with snackbaradd recaptchaV2create accountloginrequest password reset
refactor backend auth
- to handle multiple types of logins.
email and passwordanonymoussocial: googlesocial: facebook- social: twitter
- social: github
to email usersto reset their password upon forgetting it
- change return user info -- currently giving email of logged in user (even if they have multiple emails associated with their account)
- maybe give array of all account emails?
- notify user of their currently logged in method
- maybe have little svgs of each type of login method associated with account
- and logged in method is highlighted, or maybe explicitly called out as logged in
- identify common functionality and refactor. I know there are a good amount of times where I repeat code that I shouldn't.
- inconsistency - upgrading from anonymous to various users.
- social users delete the old anonymous user from database after taking what they need.
- this is because i assume that there could be an existing user that you just forgot to sign in as, and the server takes care of the rest
- username/password users use the uid of the anonymous user.
- it never assumes you have an existing account.
- i think this would be best resolved by having username / pw more closely mimic the way social providers handle it.
- this will take some refactoring i believe.
- ps: does this even matter at all?
- social users delete the old anonymous user from database after taking what they need.
- to handle multiple types of logins.
baseUrl as a part of environmentsocial provider upgrades:upgrade anonymous user to social accountfix account management pageedit pw only if you have a username/password combo for our site.merge accounts - if you have 2+ accounts, login as one to merge with other.link google providerlink facebook providerlink email and password provideralso need frontend built, making sure to send email, password, andprovider: 'emailAndPassword'
delete account:make sure to clean up all login providers when deleting account.delete providersunauthorize account from provider permissions
recaptchas everywhere that you can sign in or create account. missing in a few areas:social sign in pagesocial link pageusername/password link page
SEO Stuff:remove keywords (useless apparently)add og:add twitter:add itemprop (schema.org)read up on json-ld to determine what properties it requires
ssr module -- currently AppController eats any get requests. Put it into its own module and import it last, so it only eats unused routes, letting us use get requests.wipe out frontent functions except create anonymous user as hello world to server + dbfrontend has an unauthorize function. i think it may be useless, because the server should just handle unauthorize upon account deletion.websocket<-- see auth gateway + auth cache.update auth module middleware usageMove shared interfaces to dedicated shared folder.- there's probably a few more floating around that need refactoring
Rename fromsrctofrontendto clarify intentions.google analytics
file uploads with dropzone
flesh out blog
service worker push
second theme - simultaneously active for additional color options
comments / chat system
database migrations
copy over only a barebones package.json that just gives the dependencies, rather than the entire copy of package.json as currently implemented.
auto delete anonymous users over a certain age. maybe a cron job? maybe with a subject.
self-hosted fonts, icons (maybe?)
needed tests
- username / password auth
- forgotten password reset
- anonymous auth
- create anonymous user
- upgrade user to username / password, user id stays same
- upgrade anonymous user when account already has associated email (fails)
- social auth
- unit tests front and backend
- username / password auth
About
Angular Universal PWA Starter
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.