I did two days work to run laravel-websockets on my server. It will be nice to share with you.
Laravel WebSockets can be installed via composer:
{ | |
"attackers": [ | |
{ | |
"alliance_id": 99004804, | |
"character_id": 96780701, | |
"corporation_id": 215297637, | |
"damage_done": 1817, | |
"final_blow": true, | |
"security_status": 0.1, | |
"ship_type_id": 49710, |
// You can set up the structure without creating this entity, but when the project grows, | |
// you will need the entity for leftJoin. | |
import { BaseEntity, Entity, PrimaryColumn } from 'typeorm'; | |
@Entity() | |
export class RequestUser extends BaseEntity { | |
@PrimaryColumn('uuid') | |
requestId: string; | |
@PrimaryColumn('uuid') |
// bir sayine sonra bir değer üretir | |
const timer$ = timer(1000); | |
timer$.subscribe(value => { | |
console.log(value); // 0 | |
}); | |
// her bir saniyede bir artan değer üretir | |
const interval$ = interval(1000); | |
interval$.subscribe(value => { |
#!/usr/bin / env node | |
import express from 'express'; | |
import cors from 'cors'; | |
import bodyParser from 'body-parser'; | |
import '@lib/env'; | |
import { authChecker } from './auth-checker'; | |
import environmentErrorReporter from '@lib/environmentErrorReporter'; | |
import { appDataSource } from '@server/datasource'; | |
import { buildSchema } from 'type-graphql'; | |
import { resolvers } from './modules/resolvers'; |
[Unit] | |
Description=apollo.service | |
After=network.target | |
[Service] | |
User=root | |
Group=root | |
ExecStart=/bin/bash -c 'source /root/.nvm/nvm.sh && nvm use v16.20.2 && cd /var/www/server && yarn start' | |
Environment=NODE_ENV=production | |
StandardOutput=syslog |
import bodyParser from 'body-parser'; | |
import cors from 'cors'; | |
import express from 'express'; | |
import * as fs from 'fs'; | |
import * as jwt from 'jsonwebtoken'; | |
const accessKey = fs.readFileSync('src/keys/access_token_pkcs8.key', 'utf-8'); | |
const refreshKey = fs.readFileSync('src/keys/refresh_token_pkcs8.key', 'utf-8'); | |
const app = express(); |
import { Injectable } from '@angular/core'; | |
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpErrorResponse } from '@angular/common/http'; | |
import { Observable, BehaviorSubject } from 'rxjs'; | |
import { catchError, filter, switchMap, take } from 'rxjs/operators'; | |
import { AuthService } from '@services/auth.service'; | |
import { Router } from '@angular/router'; | |
import { TokenType } from '@app/graphql.module'; | |
@Injectable() | |
export class AuthInterceptor implements HttpInterceptor { |
// Generate AccesToken keypair | |
openssl genrsa -out access_token.pem 2048 | |
openssl rsa -in access_token.pem -pubout -out access_token_publickey.crt | |
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in access_token.pem -out access_token_pkcs8.key | |
// Generate RefreshToken keypair | |
openssl genrsa -out refresh_token.pem 2048 | |
openssl rsa -in refresh_token.pem -pubout -out refresh_token_publickey.crt | |
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in refresh_token.pem -out refresh_token_pkcs8.key |
<div x-data="{ | |
value: {{ value }} ?? '', | |
displayValue: {{ value }} ?? '', | |
demaskValue(value) { | |
this.value = value.replaceAll('$', '').replaceAll(',', '') | |
} | |
}" class="-mr-2"> | |
<input | |
type="text" | |
x-mask:dynamic="'$' + $money($input)" |