Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client tests #225

Open
wants to merge 80 commits into
base: client-tests
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
954dbb1
Add redis instance
MarhiievHE May 4, 2023
c2b132c
fix redis
MarhiievHE May 4, 2023
744b2b1
update client test
MarhiievHE May 4, 2023
ca20fb5
npm run fmt
MarhiievHE May 4, 2023
63e16c8
fixup! fix redis
MarhiievHE May 4, 2023
730622f
fixup! update client test
MarhiievHE May 4, 2023
f13bccc
fix result message
MarhiievHE May 4, 2023
d3a6082
Apply suggestions from code review
MarhiievHE May 5, 2023
01b18d4
fixup! Apply suggestions from code review
MarhiievHE May 5, 2023
336cca8
Apply suggestions from code review
tshemsedinov May 5, 2023
5204859
Update test/client.js
tshemsedinov May 5, 2023
0842251
add redis config
MarhiievHE May 5, 2023
7306f03
update compose
MarhiievHE May 5, 2023
2c2549e
update base image to node v 20
MarhiievHE May 5, 2023
267a5e5
Removed unnecessary console.logs
MarhiievHE May 5, 2023
67317da
testing with pg and Redis containers
MarhiievHE May 8, 2023
e34937c
remove debug
MarhiievHE May 8, 2023
bd5aa68
Handle startup error to prevent app termination
tshemsedinov Apr 6, 2023
7f0096f
Update impress and metacom
tshemsedinov Apr 21, 2023
65ed136
Apply prettier fixes
tshemsedinov Apr 21, 2023
eed4337
Update browser-side metacom client
tshemsedinov Apr 21, 2023
5a23b3f
Convert package_lock.json to lockfileVersion 2
tshemsedinov May 3, 2023
e5a917a
Update dependencies
tshemsedinov May 3, 2023
cd3e68e
Drop node.js 14 support, add 20
tshemsedinov May 3, 2023
4aadf35
Create config to enable/disable examples
tshemsedinov May 6, 2023
20ba5b3
update test logic
MarhiievHE May 18, 2023
a218fc6
add break test on error
MarhiievHE May 18, 2023
a9c8962
Add an API startup wait
MarhiievHE May 18, 2023
0ffedd1
debug
MarhiievHE May 18, 2023
8898a50
increase test timeout
MarhiievHE May 18, 2023
0ab34ef
update uploader
MarhiievHE May 19, 2023
771ded4
increase start delay
MarhiievHE May 20, 2023
5ecfdf6
add delay
MarhiievHE May 20, 2023
cbf2009
update action
MarhiievHE May 20, 2023
476b3b0
fix get
MarhiievHE May 20, 2023
4f6922e
metacom master Not for landing!
MarhiievHE May 20, 2023
eaf30e3
add client test
MarhiievHE May 20, 2023
d1990b1
Rename ./db folder to ./database
tshemsedinov May 31, 2023
85d7385
fix: upgrade pg from 8.10.0 to 8.11.0 (#230)
snyk-bot Jun 7, 2023
696f36c
Add instructions to renew certificates with certbot
tshemsedinov May 31, 2023
ef0b6e5
Update application/cert folder structure
tshemsedinov Jun 5, 2023
5511f43
Change `application/cert` structure
tshemsedinov Jun 8, 2023
a893de6
Update to latest metarhia libraries
tshemsedinov Jun 8, 2023
5c1d5e3
Fix cache configuration
tshemsedinov Jun 12, 2023
d360471
Fix cache configuration
tshemsedinov Jun 12, 2023
df94712
Update Metarhia to 3.0
tshemsedinov Jun 30, 2023
7047f81
Error handling approach in Metarhia 3
tshemsedinov Jun 23, 2023
8702c90
Update dependencies (#237)
tshemsedinov Jul 23, 2023
3a06d60
Update dependencies
tshemsedinov Jul 31, 2023
6c98310
Remove autocreated directory
tshemsedinov Jul 31, 2023
4c17230
Version 3.0.0
tshemsedinov Jul 31, 2023
2b89e0f
Increase Node.js version in Dockerfile
naliferov Aug 1, 2023
9889ec9
fix README. Change Node ver, add line about docker
naliferov Aug 1, 2023
3632d4a
Change repo title in readme
tshemsedinov Aug 4, 2023
eb11e4f
Fix the path to the local file in require
MarhiievHE Aug 9, 2023
4ec38c4
increase start delay
MarhiievHE Aug 9, 2023
8fcb886
add TODO
MarhiievHE Aug 21, 2023
46261a7
Update impress to 3.0.3 and other dependencies
tshemsedinov Aug 17, 2023
124fcf7
Add package files to prettier ignore
tshemsedinov Aug 17, 2023
c90646e
Update static client example
tshemsedinov Aug 20, 2023
661cdf4
Update client metacom to 3.0.5
tshemsedinov Sep 9, 2023
d84fd18
Update dependencies
tshemsedinov Sep 9, 2023
9391e39
Remove spec recorder
tshemsedinov Sep 9, 2023
60a7962
Add virtual folder example
tshemsedinov Sep 12, 2023
c71812c
Add 404 template
tshemsedinov Sep 12, 2023
387ccff
Change relative urls to absolute
tshemsedinov Sep 12, 2023
596dc00
Update content to support new Cache format
tshemsedinov Sep 12, 2023
8350292
Update dependencies
tshemsedinov Sep 13, 2023
1b4e23c
Change eslint config for static
tshemsedinov Sep 13, 2023
bc8e2e7
fix prettier
MarhiievHE Sep 14, 2023
eacafc1
Add test mode
MarhiievHE Sep 14, 2023
dd31d8c
Switch to node test runner and assert
MarhiievHE Sep 14, 2023
fb8ee4a
Switch to metavm for are loading configs
MarhiievHE Sep 15, 2023
f9cfcbd
fix db init scripts path
MarhiievHE Sep 15, 2023
5de3b2b
update testing
MarhiievHE Sep 15, 2023
6e59324
update test
MarhiievHE Sep 15, 2023
9a129ae
update test
MarhiievHE Sep 15, 2023
fee12c7
remove test-api container
MarhiievHE Sep 15, 2023
d2fa9dd
used once function instead of Promice
MarhiievHE Sep 21, 2023
dc051cb
Add an example of subscribing and unsubscribing in API using Set
MarhiievHE Sep 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions application/api/example.1/getClientInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
method: async () => {
const { uuid, session, client } = context;
const { ip } = client;
const { token, accountId } = session;
return { result: { ip, token, accountId, uuid } };
const { token } = session;
const accountId = session.state.accountId;
const result = { ip, token, accountId, uuid };
return { result };
},
});
2 changes: 1 addition & 1 deletion application/api/example.1/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
router({ method, args, verb, headers }) {
const ip = context.client.ip;
console.log({ method, args, ip, verb, headers });
return {success:true, method, args, ip, verb, headers };
return { success: true, method, args, ip, verb, headers };
},
});
2 changes: 1 addition & 1 deletion application/api/example.1/redisGet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
({
access: 'public',
method: async ({ key }) => {
const result = await lib.redis.get(key);
const result = await db.redis.get(key);
return { result };
},
});
2 changes: 1 addition & 1 deletion application/api/example.1/redisSet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
({
access: 'public',
method: async ({ key, value }) => {
const result = await lib.redis.set(key, value);
const result = await db.redis.set(key, value);
return { result };
},
});
2 changes: 1 addition & 1 deletion application/api/example.1/uploadFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ async ({ name, data }) => {
if (filePath.startsWith(tmpPath)) {
await node.fsp.writeFile(filePath, buffer);
}
return { uploaded: data.length };
return { uploaded: data.data.length };
};
8 changes: 8 additions & 0 deletions application/api/files.1/upload.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
async ({ streamId, name }) => {
const filePath = `./application/resources/${name}`;
let exist = false;
try {
await node.fsp.access(filePath);
exist = true;
} catch (err) {
console.error(err);
}
MarhiievHE marked this conversation as resolved.
Show resolved Hide resolved
if (exist) return { result: `File ${name} already exist on server` };
MarhiievHE marked this conversation as resolved.
Show resolved Hide resolved
// Get incoming stream by streamId sent from client
const readable = context.client.getStream(streamId);
// Create nodejs stream to write file on server
Expand Down
2 changes: 1 addition & 1 deletion application/api/hook.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
router({ method, args, verb, headers }) {
const ip = context.client.ip;
console.log({ method, args, ip, verb, headers });
return {};
return { success: true, args };
},
});
8 changes: 1 addition & 7 deletions application/db/redis/get.js
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
(key) =>
new Promise((resolve, reject) => {
lib.redis.client.get(key, (err, result) => {
if (err) reject(err);
else resolve(result);
});
});
(key) => db.redis.client.get(key);
8 changes: 1 addition & 7 deletions application/db/redis/set.js
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
(key, value) =>
new Promise((resolve, reject) => {
lib.redis.client.set(key, value, (err, result) => {
if (err) reject(err);
else resolve(result);
});
});
async (key, value) => db.redis.client.set(key, value);
2 changes: 1 addition & 1 deletion application/db/redis/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ async () => {
}
client.quit();
});
//await client.connect();
await client.connect();
};
18 changes: 9 additions & 9 deletions application/lib/task1/start.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
async () => {
if (application.worker.id === 'W1') {
tshemsedinov marked this conversation as resolved.
Show resolved Hide resolved
setTimeout(async () => {
const res = await application.scheduler.add({
name: 'name',
every: 'Sep 10th 10s',
args: { i: 2 },
run: 'lib.task1.f1',
});
console.log('Add task', res);
}, 1000);
// setTimeout(async () => {
// const res = await application.scheduler.add({
// name: 'name',
// every: 'Sep 10th 10s',
// args: { i: 2 },
// run: 'lib.task1.f1',
// });
// console.log('Add task', res);
// }, 1000);
tshemsedinov marked this conversation as resolved.
Show resolved Hide resolved
}
};
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ services:
- 127.0.0.1:5432:5432
restart: always

redis-example:
image: redis:alpine
container_name: redis-example
ports:
- 127.0.0.1:6379:6379
restart: always
networks:
default:
name: api-example-network
Loading