server url fix, remove container

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-08-09 14:36:44 +02:00
parent 757a1308d4
commit e4cc53966a
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
3 changed files with 18 additions and 20 deletions

View File

@ -71,18 +71,18 @@ export const websiteUrl = siteBucket.websiteEndpoint
// D O C K E R // D O C K E R
const service = new cloud.Service("dev-server", { // const service = new cloud.Service("dev-server", {
containers: { // containers: {
server: { // server: {
build: "./dev-server", // build: "./dev-server",
memory: 128, // memory: 128,
ports: [{ port: 3333 }], // ports: [{ port: 3333 }],
}, // },
}, // },
replicas: 1, // replicas: 1,
}) // })
export const serverEndpoint = service.defaultEndpoint.hostname // export const serverEndpoint = service.defaultEndpoint.hostname
// //
// L O G I N // L O G I N
@ -95,15 +95,12 @@ const api = new awsx.apigateway.API("login", {
path: "/", path: "/",
method: "POST", method: "POST",
eventHandler: async (event) => { eventHandler: async (event) => {
console.log(event.body)
console.log(serverEndpoint.get())
let body = event.body; let body = event.body;
if (event.isBase64Encoded) { if (event.isBase64Encoded) {
body = Buffer.from(body as string, 'base64').toString() body = Buffer.from(body as string, 'base64').toString()
} }
const result = handle(body, serverEndpoint.get()) const result = handle(body, 'wss://pacific-refuge-43514.herokuapp.com/')
return { return {
statusCode: result.statusCode, statusCode: result.statusCode,
headers: { headers: {

View File

@ -31,7 +31,7 @@ export default async () => {
GetClient: async (token: string, endpoint: string): Promise<Client> => { GetClient: async (token: string, endpoint: string): Promise<Client> => {
if (client === undefined) { if (client === undefined) {
return await createClient((handler: TxHander) => { return await createClient((handler: TxHander) => {
const url = `ws://${endpoint}:3333/${token}` const url = `${endpoint}/${token}`
console.log('connecting to', url) console.log('connecting to', url)
return connect(url, handler) return connect(url, handler)
}) })

View File

@ -39,7 +39,7 @@ describe('server', () => {
it('should send many requests', (done) => { it('should send many requests', (done) => {
const conn = connect() const conn = connect()
const total = 10 const total = 10
// const start = Date.now() const start = Date.now()
conn.on('open', () => { conn.on('open', () => {
for (let i = 0; i < total; i++) { for (let i = 0; i < total; i++) {
conn.send(serialize({ method: 'findAll', params: ['core:class:Class', {}], id: i })) conn.send(serialize({ method: 'findAll', params: ['core:class:Class', {}], id: i }))
@ -47,12 +47,13 @@ describe('server', () => {
}) })
let received = 0 let received = 0
conn.on('message', (msg: string) => { conn.on('message', (msg: string) => {
readResponse(msg) const resp = readResponse(msg)
console.log(resp.id)
if (++received === total) { if (++received === total) {
// console.log('resp:', resp, ' Time: ', Date.now() - start) console.log(' Time: ', Date.now() - start)
conn.close() conn.close()
done()
} }
}) })
conn.onclose = () => { console.log('closed'); done() }
}) })
}) })