- Notifications
You must be signed in to change notification settings - Fork6
yantrab/nest-angular
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is a repo for a starter appliation for a Single Page MEAN Stack applicationincludes nest js + fastify + http2 + angular 7 + angular material + client api generator.
git clone https://github.com/yantrab/nest-angular.gitcd .\nest-angularnpm i
To use ssl with localhost, open cmd one level above the root and run:
choco install mkcertmkcert localhostmkcert -install
npm run debug-server
npm run build-client
npm run dev
Hit F5 and select the process
@Controller('rest/auth')exportclassAuthController{ @Post('login')asynclogin(@Body()user:LoginRequest, @Req()req):Promise<User>{returnreq.user;} @Get('getUserAuthenticated')asyncgetUserAuthenticated(@Req()req):Promise<{user:User}>{return{user:req.user};}}
npm run gen-client
@Injectable()exportclassAuthController{asynclogin(user:LoginRequest):Promise<User>{returnnewPromise(resolve=>this.api.post('rest/auth/login',user).subscribe((data:any)=>resolve(plainToClass(User,<User>data))),);}asyncgetUserAuthenticated():Promise<{user:User}>{returnnewPromise(resolve=>this.api.get('rest/auth/getUserAuthenticated').subscribe((data:any)=>resolve(data)));}constructor(privatereadonlyapi:APIService){}}
cd clientnpm run cordova:initnpm run build:prod:cordovanpm run cordova:run:browserexportclassUserextendsEntity{fName:string;lName:string;roles:Role[];getfullName(){returnthis.fName+' '+this.lName;}}
By usingclass-tranformer (auto generate), you can do:
this.authService.login(this.form.value).then(user=>{console.log(user.fullName);});
Shared validation usingclass-validator
exportclassLoginRequest{ @IsEmail()email:string @Length(6,10)password:string}})
just usevalidation pipe
constructor(privatedynaFB:DynaFormBuilder){this.dynaFB.buildFormFromClass(LoginRequest).then(form=>this.form=form);}
By inheritance from Poly class you can do the next thing:
// Class declerationexportabstractclassFilterextendsPoly{}exportclassCheckboxFilterextendsFilter{}exportclassDropdownFilterextendsFilter{} @Component({selector:'mf-root',template:` <div fxLayout='column' fxFlex='200px'> <p-filter [filter]="filter1"></p-filter> <p-filter [filter]="filter2"></p-filter> <div> `,styles:[]})exportclassMFComponent{ filter1:Filter; filter2:Filter;constructor(){this.filter1=newCheckboxFilter({options:[{_id:'1',name:'name1'},{_id:'2',name:'name2'}],selected:{_id:'2',name:'name2'}});this.filter2=newDropdownFilter({options:[{_id:'1',name:'name1'},{_id:'2',name:'name2'}],selected:{_id:'2',name:'name2'}});}}
-- Client generator with full types.
-- Auto transform result to real object
-- Share models between server & client
recomended vscode extensions
- Angular Language Service
- angular2-inline
- SCSS Formatter
- TSLint
sudo apt-get updatesudo apt-get install gitsudo apt-get install nodejssudo apt-get install npmgit clonehttps://github.com/yantrab/nest-angular.git
//DBhttps://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-debian-9
sudo ufw allow from 62.219.113.155/32 to any port 27017sudo ufw allow from 10.110.0.3/32 to any port 27017sudo iptables -A INPUT -s 188.64.207.118 -p tcp --destination-port 27017 -m state --state NEW,ESTABLISHED -j ACCEPTsudo iptables -A OUTPUT -d 188.64.207.118 -p tcp --source-port 27017 -m state --state ESTABLISHED -j ACCEPTsudo systemctl restart mongod
echo "export const macroConf = {db: {user: '?',password: '?',server: '?',database: '?',debug: false,max: 500,min: 0,idle: 5000,acquire: 20000,evict: 30000,handleDisconnects: true,connectionTimeout: 300000,requestTimeout: 300000,}};" > config.ts
##Depolyadduser yanivusermod -aG sudo yanivapt updateapt install ufwufw allow OpenSSHufw enableufw statusssh yaniv@your_server_ip
sudo apt updatesudo apt install nginxsudo ufw allow 'Nginx HTTP'sudo ufw statussystemctl status nginx
sudo apt install curlcurl -sLhttps://deb.nodesource.com/setup_10.x -o nodesource_setup.shsudo bash nodesource_setup.shsudo apt install nodejssudo apt install gitgit config --global user.name "yantrab"git config --global user.email "yantrab@gmail.com"mkdir tadorcd tadorgit clonehttps://github.com/yantrab/nest-angular.gitcd nest-angularnpm i
// copy dist from windows
scp -r dist yaniv@128.199.41.162:/home/yaniv/tador/nest-angular/clientscp -r dist yaniv@178.62.237.25:/home/yaniv/tador/nest-angular/client
sudo npm install pm2@latest -gcd serverpm2 start npm -- startsudo nano /etc/nginx/sites-available/default
server {...location / {proxy_passhttp://localhost:4200;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection 'upgrade';proxy_set_header Host $host;proxy_cache_bypass $http_upgrade;}...}
sudo systemctl reload nginx
About
Full-stack with nest js & angular 8
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.