Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
b64519c8
Commit
b64519c8
authored
Jan 08, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor server code into a module
parent
dab4a931
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
31 deletions
+43
-31
ethsim
remix-simulator/bin/ethsim
+3
-1
server.js
remix-simulator/src/server.js
+40
-30
No files found.
remix-simulator/bin/ethsim
View file @
b64519c8
#!/usr/bin/env node
#!/usr/bin/env node
require
(
'../src/server'
);
const
Server
=
require
(
'../src/server'
);
const
server
=
new
Server
()
server
.
start
()
remix-simulator/src/server.js
View file @
b64519c8
...
@@ -5,35 +5,45 @@ const expressWs = require('express-ws')
...
@@ -5,35 +5,45 @@ const expressWs = require('express-ws')
const
Provider
=
require
(
'./provider'
)
const
Provider
=
require
(
'./provider'
)
const
log
=
require
(
'./utils/logs.js'
)
const
log
=
require
(
'./utils/logs.js'
)
expressWs
(
app
)
class
Server
{
var
provider
=
new
Provider
()
constructor
()
{
this
.
provider
=
new
Provider
()
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
}
app
.
use
(
bodyParser
.
json
())
start
(
host
,
port
)
{
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
expressWs
(
app
)
res
.
send
(
'Welcome to remix-simulator'
)
})
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
app
.
use
(
bodyParser
.
json
())
app
.
use
((
req
,
res
)
=>
{
provider
.
sendAsync
(
req
.
body
,
(
err
,
jsonResponse
)
=>
{
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
if
(
err
)
{
res
.
send
(
'Welcome to remix-simulator'
)
return
res
.
send
(
JSON
.
stringify
({
error
:
err
}))
})
}
res
.
send
(
jsonResponse
)
app
.
use
((
req
,
res
)
=>
{
})
provider
.
sendAsync
(
req
.
body
,
(
err
,
jsonResponse
)
=>
{
})
if
(
err
)
{
return
res
.
send
(
JSON
.
stringify
({
error
:
err
}))
app
.
ws
(
'/'
,
(
ws
,
req
)
=>
{
}
ws
.
on
(
'message'
,
function
(
msg
)
{
res
.
send
(
jsonResponse
)
provider
.
sendAsync
(
JSON
.
parse
(
msg
),
(
err
,
jsonResponse
)
=>
{
})
if
(
err
)
{
})
return
ws
.
send
(
JSON
.
stringify
({
error
:
err
}))
}
app
.
ws
(
'/'
,
(
ws
,
req
)
=>
{
ws
.
send
(
JSON
.
stringify
(
jsonResponse
))
ws
.
on
(
'message'
,
function
(
msg
)
{
provider
.
sendAsync
(
JSON
.
parse
(
msg
),
(
err
,
jsonResponse
)
=>
{
if
(
err
)
{
return
ws
.
send
(
JSON
.
stringify
({
error
:
err
}))
}
ws
.
send
(
JSON
.
stringify
(
jsonResponse
))
})
})
})
})
})
})
app
.
listen
(
8545
,
()
=>
log
(
'Remix Simulator listening on port 8545!'
))
app
.
listen
(
8545
,
()
=>
log
(
'Remix Simulator listening on port 8545!'
))
}
}
module
.
exports
=
Server
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment