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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
ethsim
remix-simulator/bin/ethsim
+3
-1
server.js
remix-simulator/src/server.js
+21
-11
No files found.
remix-simulator/bin/ethsim
View file @
b64519c8
#!/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,27 +5,32 @@ const expressWs = require('express-ws')
const
Provider
=
require
(
'./provider'
)
const
log
=
require
(
'./utils/logs.js'
)
expressWs
(
app
)
class
Server
{
var
provider
=
new
Provider
()
constructor
()
{
this
.
provider
=
new
Provider
()
}
start
(
host
,
port
)
{
expressWs
(
app
)
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
app
.
use
(
bodyParser
.
json
())
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
app
.
use
(
bodyParser
.
json
())
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
res
.
send
(
'Welcome to remix-simulator'
)
})
})
app
.
use
((
req
,
res
)
=>
{
app
.
use
((
req
,
res
)
=>
{
provider
.
sendAsync
(
req
.
body
,
(
err
,
jsonResponse
)
=>
{
if
(
err
)
{
return
res
.
send
(
JSON
.
stringify
({
error
:
err
}))
}
res
.
send
(
jsonResponse
)
})
})
})
app
.
ws
(
'/'
,
(
ws
,
req
)
=>
{
app
.
ws
(
'/'
,
(
ws
,
req
)
=>
{
ws
.
on
(
'message'
,
function
(
msg
)
{
provider
.
sendAsync
(
JSON
.
parse
(
msg
),
(
err
,
jsonResponse
)
=>
{
if
(
err
)
{
...
...
@@ -34,6 +39,11 @@ app.ws('/', (ws, req) => {
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