Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Even Gultvedt
MiniProject2019V2
Commits
3f2952f6
Commit
3f2952f6
authored
Nov 21, 2019
by
Even Gultvedt
Browse files
Added flow stuff
parent
a91c9632
Pipeline
#58596
passed with stage
in 1 minute and 23 seconds
Changes
34
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
.flowconfig
0 → 100644
View file @
3f2952f6
[libs]
/client/flow-typed/npm
/server/flow-typed/npm
[ignore]
.*/tests/.*
\ No newline at end of file
.gitignore
View file @
3f2952f6
...
...
@@ -90,4 +90,4 @@ typings/
.dynamodb/
.gitignore
.idea/
\ No newline at end of file
.idea/
.gitlab-ci.yml
View file @
3f2952f6
...
...
@@ -12,17 +12,17 @@ variables:
before_script
:
-
cd server
-
npm install
-
cd ../client
-
npm install
#
- cd ../client
#
- npm install
# Run JEST tests
run_tests
:
stage
:
test
script
:
-
cd ../server
-
npm test
-
cd ../client
#- cd ../server
-
npm test
#- cd ../client
#- npm test
artifacts
:
paths
:
-
coverage/
client/.npmrc
0 → 100644
View file @
3f2952f6
package-lock=false
client/package-lock.json
deleted
100644 → 0
View file @
a91c9632
This diff is collapsed.
Click to expand it.
client/package.json
View file @
3f2952f6
{
"name"
:
"client"
,
"version"
:
"0.1.0"
,
"private"
:
true
,
"version"
:
"1.0.0"
,
"dependencies"
:
{
"mysql"
:
"^2.17.1"
,
"react"
:
"^16.11.0"
,
"react-bootstrap"
:
"^1.0.0-beta.14"
,
"react-dom"
:
"^16.11.0"
,
"react-native-text-ticker"
:
"^1.0.0"
,
"react-scripts"
:
"3.2.0"
,
"react-simplified"
:
"^1.6.1"
,
"react-ticker"
:
"^1.2.1"
,
"react-native-text-ticker"
:
"^1.0.0"
,
"mysql"
:
"^2.17.1"
"axios"
:
"^0.19.0"
,
"cross-env"
:
"^6.0.3"
,
"history"
:
"^4.10.1"
,
"jest"
:
"^24.9.0"
,
"react-router-dom"
:
"^5.1.2"
,
"flow-bin"
:
"^0.112.0"
},
"scripts"
:
{
"start"
:
"react-scripts start"
,
...
...
@@ -32,11 +37,5 @@
"last 1 firefox version"
,
"last 1 safari version"
]
},
"devDependencies"
:
{
"axios"
:
"^0.19.0"
,
"history"
:
"^4.10.1"
,
"react-native-text-ticker"
:
"^1.0.0"
,
"react-router-dom"
:
"^5.1.2"
}
}
client/src/.flowconfig
deleted
100644 → 0
View file @
a91c9632
[ignore]
[include]
[libs]
[lints]
[options]
[strict]
client/src/Article.js
View file @
3f2952f6
//@flow
module
.
exports
=
class
Article
{
static
constantURL
:
string
=
'
https://png.pngtree.com/png-clipart/20190515/original/pngtree-coffee-time-png-image_3626459.jpg
'
;
id
:
number
;
...
...
client/src/ArticleWidgets.js
View file @
3f2952f6
//@flow
import
{
Component
}
from
"
react-simplified
"
;
import
{
articleStore
}
from
"
./stores
"
;
import
{
NavLink
}
from
"
react-router-dom
"
;
...
...
@@ -42,7 +44,6 @@ export class ArticleGrid extends Component<{ category?: number }> {
}
export
class
SingleArticle
extends
Component
<
{
match
:
{
params
:
{
id
:
number
}
}
}
>
{
constructor
(
props
)
{
super
(
props
);
if
(
this
.
props
.
match
!=
null
&&
this
.
props
.
match
.
params
.
id
)
{
...
...
client/src/CommentWidgets.js
View file @
3f2952f6
...
...
@@ -59,11 +59,11 @@ export class AddComment extends Component<{ article_id: number }> {
}
addComment
()
{
let
id
=
Math
.
max
(...
articleStore
.
currentArticle
.
comments
.
map
(
e
=>
e
.
id
))
+
1
;
let
id
:
number
=
Math
.
max
(...
articleStore
.
currentArticle
.
comments
.
map
(
e
=>
e
.
id
))
+
1
;
if
(
id
<
0
)
{
id
=
0
;
}
let
comment
=
new
Comment
(
id
,
this
.
author
,
this
.
content
,
articleStore
.
currentArticle
.
id
);
let
comment
:
Comment
=
new
Comment
(
id
,
this
.
author
,
this
.
content
,
articleStore
.
currentArticle
.
id
);
console
.
log
(
comment
);
this
.
author
=
''
;
this
.
content
=
''
;
...
...
client/src/index.js
View file @
3f2952f6
...
...
@@ -5,7 +5,7 @@ import {HashRouter, Route} from "react-router-dom";
import
{
articleStore
}
from
"
./stores
"
;
import
{
AddArticle
,
EditArticle
,
SingleArticle
}
from
"
./ArticleWidgets
"
;
const
root
=
document
.
getElementById
(
'
root
'
);
const
root
:
any
=
document
.
getElementById
(
'
root
'
);
if
(
root
)
articleStore
.
getCategories
().
then
(
res
=>
{
ReactDOM
.
render
(
...
...
client/src/stores.js
View file @
3f2952f6
...
...
@@ -15,10 +15,10 @@ class ArticleStore {
articles
:
Article
[]
=
[];
currentArticle
:
Article
=
null
;
categories
=
{};
categories
:
any
=
{};
getIds
(){
return
axios
.
get
<
number
[]
>
(
"
http://localhost:4001/ids
"
).
then
(
response
=>
response
.
data
).
then
(
data
=>
data
.
map
(
element
=>
element
.
id
));
return
axios
.
get
(
"
http://localhost:4001/ids
"
).
then
(
response
=>
response
.
data
).
then
(
data
=>
data
.
map
(
element
=>
element
.
id
));
}
getCategories
(){
...
...
@@ -35,7 +35,7 @@ class ArticleStore {
return
axios
.
get
(
'
http://localhost:4001/article/
'
+
id
).
then
(
response
=>
{
if
(
response
.
data
[
0
]){
this
.
currentArticle
=
this
.
createArticle
(
response
.
data
[
0
]);
let
article
=
this
.
articles
.
find
(
a
=>
this
.
currentArticle
.
id
===
a
.
id
);
let
article
:
Article
=
this
.
articles
.
find
(
a
=>
this
.
currentArticle
.
id
===
a
.
id
);
if
(
article
){
Object
.
assign
(
article
,
{...
this
.
currentArticle
});
}
...
...
@@ -85,9 +85,9 @@ class ArticleStore {
});
}
postArticle
(
article
:
Article
){
postArticle
(
article
:
Article
)
:
any
{
let
data
=
{
let
data
:
{
id
:
number
,
author
:
string
,
date
:
string
,
category
:
number
,
important
:
boolean
,
headline
:
string
,
imageURL
:
string
,
content
:
string
}
=
{
id
:
article
.
id
,
author
:
article
.
author
,
date
:
article
.
time
,
...
...
@@ -110,12 +110,12 @@ class ArticleStore {
this
.
currentArticle
.
imageURL
=
article
.
imageURL
;
this
.
currentArticle
.
content
=
article
.
content
;
let
articleFromList
=
this
.
articles
.
find
(
a
=>
this
.
currentArticle
.
id
===
a
.
id
);
let
articleFromList
:
Article
=
this
.
articles
.
find
(
a
=>
this
.
currentArticle
.
id
===
a
.
id
);
if
(
articleFromList
){
Object
.
assign
(
articleFromList
,
{...
this
.
currentArticle
});
}
let
data
=
{
let
data
:
{
author
:
string
,
title
:
string
,
imageURL
:
string
,
time
:
string
,
content
:
string
,
category
:
number
,
important
:
boolean
}
=
{
author
:
article
.
author
,
title
:
article
.
title
,
imageURL
:
article
.
imageURL
,
...
...
@@ -132,7 +132,7 @@ class ArticleStore {
postComment
(
comment
:
Comment
){
let
data
=
{
let
data
:
{
id
:
number
,
author
:
string
,
content
:
string
,
articles_id
:
number
}
=
{
id
:
comment
.
id
,
author
:
comment
.
author
,
content
:
comment
.
content
,
...
...
@@ -145,7 +145,7 @@ class ArticleStore {
}
deleteComment
(
id
:
number
){
let
data
=
{
let
data
:
{
id
:
number
,
articles_id
:
number
}
=
{
id
:
id
,
articles_id
:
this
.
currentArticle
.
id
};
...
...
@@ -153,4 +153,6 @@ class ArticleStore {
}
}
export
let
articleStore
=
sharedComponentData
(
new
ArticleStore
());
\ No newline at end of file
export
let
articleStore
=
sharedComponentData
(
new
ArticleStore
());
module
.
export
=
articleStore
;
\ No newline at end of file
client/tests/articleStore.test.js
View file @
3f2952f6
//@flow
let
mysql
=
require
(
'
mysql
'
);
import
{
articleStore
}
from
'
../src/stores
'
;
const
Comment
=
require
(
'
../src/Comment
'
);
const
Article
=
require
(
'
../src/Article
'
);
let
privatePool
=
require
(
'
../../server/src/database
'
).
pool
;
const
runsqlfile
=
require
(
'
../../server/tests/runsqlfile.js
'
);
let
pool
=
mysql
.
createPool
({
connectionLimit
:
1
,
host
:
"
mysql
"
,
user
:
"
root
"
,
password
:
"
secret
"
,
database
:
"
supertestdb
"
,
debug
:
false
,
multipleStatements
:
true
});
const
runsqlfile
=
require
(
'
../../server/tests/runsqlfile
'
);
let
privatepool
=
mysql
.
createPool
({
connectionLimit
:
2
,
host
:
"
mysql.stud.iie.ntnu.no
"
,
user
:
"
evengu
"
,
password
:
"
O7KhlwWQ
"
,
database
:
"
evengu
"
,
debug
:
false
}
);
beforeAll
(
done
=>
{
console
.
log
(
"
Hello
"
);
runsqlfile
(
"
../server/tests/createTables.sql
"
,
privatePool
,
()
=>
{
runsqlfile
(
"
../server/tests/createTestData.sql
"
,
privatePool
,
done
);
runsqlfile
(
"
../server/tests/createTables.sql
"
,
privatepool
,
()
=>
{
runsqlfile
(
"
../server/tests/createTestData.sql
"
,
privatepool
,
done
);
});
articleStore
.
currentArticle
=
null
;
articleStore
.
articles
=
[];
articleStore
.
categories
=
{};
});
afterAll
(
pool
.
end
());
afterAll
(
()
=>
private
pool
.
end
());
test
(
"
Hello
"
,
done
=>
{
expect
(
1
).
toBe
(
2
);
done
();
});
/*
test("Checking Comment() constructor", done => {
let comment = new Comment(0, "evengu", "Some content", 0);
expect(comment.id).toBe(0);
...
...
@@ -130,4 +128,4 @@ test("Delete comment", done => {
})
})
})
});
});
*/
flow-typed/npm/axios_v0.19.x.js
0 → 100644
View file @
3f2952f6
// flow-typed signature: e58955fd9864ac5f1c162da932f492d9
// flow-typed version: 358ad43cd9/axios_v0.19.x/flow_>=v0.80.x
declare
module
'
axios
'
{
import
type
{
Agent
as
HttpAgent
}
from
'
http
'
;
import
type
{
Agent
as
HttpsAgent
}
from
'
https
'
;
declare
type
AxiosTransformer
<
T
>
=
(
data
:
T
,
headers
?:
{
[
key
:
string
]:
any
}
)
=>
any
;
declare
type
ProxyConfig
=
{
|
host
:
string
,
port
:
number
,
auth
?:
{
username
:
string
,
password
:
string
,
},
protocol
?:
string
,
|
};
declare
class
Cancel
{
constructor
(
message
?:
string
):
Cancel
;
message
:
string
;
}
declare
type
Canceler
=
(
message
?:
string
)
=>
void
;
declare
type
CancelTokenSource
=
{
|
token
:
CancelToken
,
cancel
:
Canceler
,
|
};
declare
class
CancelToken
{
constructor
(
executor
:
(
cancel
:
Canceler
)
=>
void
):
void
;
static
source
():
CancelTokenSource
;
promise
:
Promise
<
Cancel
>
;
reason
?:
Cancel
;
throwIfRequested
():
void
;
}
declare
type
Method
=
|
'
get
'
|
'
GET
'
|
'
delete
'
|
'
DELETE
'
|
'
head
'
|
'
HEAD
'
|
'
options
'
|
'
OPTIONS
'
|
'
post
'
|
'
POST
'
|
'
put
'
|
'
PUT
'
|
'
patch
'
|
'
PATCH
'
;
declare
type
ResponseType
=
|
'
arraybuffer
'
|
'
blob
'
|
'
document
'
|
'
json
'
|
'
text
'
|
'
stream
'
;
declare
type
AxiosAdapter
=
(
config
:
AxiosXHRConfig
<
any
>
)
=>
Promise
<
AxiosXHR
<
any
>>
;
declare
type
AxiosXHRConfigBase
<
T
,
R
=
T
>
=
{
adapter
?:
AxiosAdapter
,
auth
?:
{
username
:
string
,
password
:
string
,
},
baseURL
?:
string
,
cancelToken
?:
CancelToken
,
headers
?:
{
[
key
:
string
]:
any
},
httpAgent
?:
HttpAgent
,
httpsAgent
?:
HttpsAgent
,
maxContentLength
?:
number
,
maxRedirects
?:
number
,
socketPath
?:
string
|
null
,
params
?:
{
[
key
:
string
]:
any
},
paramsSerializer
?:
(
params
:
{
[
key
:
string
]:
any
})
=>
string
,
onUploadProgress
?:
(
progressEvent
:
ProgressEvent
)
=>
void
,
onDownloadProgress
?:
(
progressEvent
:
ProgressEvent
)
=>
void
,
proxy
?:
ProxyConfig
|
false
,
responseType
?:
ResponseType
,
timeout
?:
number
,
transformRequest
?:
AxiosTransformer
<
T
>
|
Array
<
AxiosTransformer
<
T
>>
,
transformResponse
?:
AxiosTransformer
<
R
>
|
Array
<
AxiosTransformer
<
R
>>
,
validateStatus
?:
(
status
:
number
)
=>
boolean
,
withCredentials
?:
boolean
,
xsrfCookieName
?:
string
,
xsrfHeaderName
?:
string
,
};
declare
type
AxiosXHRConfig
<
T
,
R
=
T
>
=
{
|
...
$Exact
<
AxiosXHRConfigBase
<
T
,
R
>>
,
data
?:
T
,
method
?:
Method
,
url
:
string
,
|
};
declare
type
AxiosXHRConfigShape
<
T
,
R
=
T
>
=
$Shape
<
AxiosXHRConfig
<
T
,
R
>>
;
declare
type
AxiosXHR
<
T
,
R
=
T
>
=
{
config
:
AxiosXHRConfig
<
T
,
R
>
,
data
:
R
,
headers
:
?{
[
key
:
string
]:
any
},
status
:
number
,
statusText
:
string
,
request
:
http$ClientRequest
<>
|
XMLHttpRequest
|
mixed
,
};
declare
type
AxiosInterceptorIdent
=
number
;
declare
type
AxiosRequestInterceptor
<
T
,
R
=
T
>
=
{
|
use
(
onFulfilled
:
?(
response
:
AxiosXHRConfig
<
T
,
R
>
)
=>
Promise
<
AxiosXHRConfig
<
mixed
>>
|
AxiosXHRConfig
<
mixed
>
,
onRejected
:
?(
error
:
mixed
)
=>
mixed
):
AxiosInterceptorIdent
,
eject
(
ident
:
AxiosInterceptorIdent
):
void
,
|
};
declare
type
AxiosResponseInterceptor
<
T
,
R
=
T
>
=
{
|
use
(
onFulfilled
:
?(
response
:
AxiosXHR
<
T
,
R
>
)
=>
mixed
,
onRejected
:
?(
error
:
mixed
)
=>
mixed
):
AxiosInterceptorIdent
,
eject
(
ident
:
AxiosInterceptorIdent
):
void
,
|
};
declare
type
AxiosPromise
<
T
,
R
=
T
>
=
Promise
<
AxiosXHR
<
T
,
R
>>
;
declare
class
Axios
{
<
T
,
R
>
(
config
:
AxiosXHRConfig
<
T
,
R
>
|
string
,
config
?:
AxiosXHRConfigShape
<
T
,
R
>
):
AxiosPromise
<
T
,
R
>
;
constructor
<
T
,
R
>
(
config
?:
AxiosXHRConfigBase
<
T
,
R
>
):
void
;
request
<
T
,
R
>
(
config
:
AxiosXHRConfig
<
T
,
R
>
|
string
,
config
?:
AxiosXHRConfigShape
<
T
,
R
>
):
AxiosPromise
<
T
,
R
>
;
delete
<
R
>
(
url
:
string
,
config
?:
AxiosXHRConfigBase
<
mixed
,
R
>
):
AxiosPromise
<
mixed
,
R
>
;
get
<
R
>
(
url
:
string
,
config
?:
AxiosXHRConfigBase
<
mixed
,
R
>
):
AxiosPromise
<
mixed
,
R
>
;
head
<
R
>
(
url
:
string
,
config
?:
AxiosXHRConfigBase
<
mixed
,
R
>
):
AxiosPromise
<
mixed
,
R
>
;
post
<
T
,
R
>
(
url
:
string
,
data
?:
T
,
config
?:
AxiosXHRConfigBase
<
T
,
R
>
):
AxiosPromise
<
T
,
R
>
;
put
<
T
,
R
>
(
url
:
string
,
data
?:
T
,
config
?:
AxiosXHRConfigBase
<
T
,
R
>
):
AxiosPromise
<
T
,
R
>
;
patch
<
T
,
R
>
(
url
:
string
,
data
?:
T
,
config
?:
AxiosXHRConfigBase
<
T
,
R
>
):
AxiosPromise
<
T
,
R
>
;
interceptors
:
{
request
:
AxiosRequestInterceptor
<
mixed
>
,
response
:
AxiosResponseInterceptor
<
mixed
>
,
};
defaults
:
{
|
...
$Exact
<
AxiosXHRConfigBase
<
mixed
>>
,
headers
:
{
[
key
:
string
]:
any
},
|
};
getUri
<
T
,
R
>
(
config
?:
AxiosXHRConfig
<
T
,
R
>
):
string
;
}
declare
class
AxiosError
<
T
,
R
=
T
>
extends
Error
{
config
:
AxiosXHRConfig
<
T
,
R
>
;
request
?:
http$ClientRequest
<>
|
XMLHttpRequest
;
response
?:
AxiosXHR
<
T
,
R
>
;
code
?:
string
;
isAxiosError
:
boolean
;
}
declare
interface
AxiosExport
extends
Axios
{
<
T
,
R
>
(
config
:
AxiosXHRConfig
<
T
,
R
>
|
string
,
config
?:
AxiosXHRConfigShape
<
T
,
R
>
):
AxiosPromise
<
T
,
R
>
;
Axios
:
typeof
Axios
;
Cancel
:
typeof
Cancel
;
CancelToken
:
typeof
CancelToken
;
isCancel
(
value
:
any
):
boolean
;
create
(
config
?:
AxiosXHRConfigBase
<
any
>
):
Axios
;
all
:
typeof
Promise
.
all
;
spread
<
T
,
R
>
(
callback
:
(...
args
:
T
)
=>
R
):
(
array
:
T
)
=>
R
;
}
declare
type
$AxiosXHRConfigBase
<
T
,
R
=
T
>
=
AxiosXHRConfigBase
<
T
,
R
>
;
declare
type
$AxiosXHRConfig
<
T
,
R
=
T
>
=
AxiosXHRConfig
<
T
,
R
>
;
declare
type
$AxiosXHR
<
T
,
R
=
T
>
=
AxiosXHR
<
T
,
R
>
;
declare
type
$AxiosError
<
T
,
R
=
T
>
=
AxiosError
<
T
,
R
>
;
declare
module
.
exports
:
AxiosExport
;
}
flow-typed/npm/cross-env_vx.x.x.js
0 → 100644
View file @
3f2952f6
// flow-typed signature: b9083257ecac2cc03c9322a226358985
// flow-typed version: <<STUB>>/cross-env_v^6.0.3
/**
* This is an autogenerated libdef stub for:
*
* 'cross-env'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare
module
'
cross-env
'
{
declare
module
.
exports
:
any
;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare
module
'
cross-env/src/bin/cross-env-shell
'
{
declare
module
.
exports
:
any
;
}
declare
module
'
cross-env/src/bin/cross-env
'
{
declare
module
.
exports
:
any
;
}
declare
module
'
cross-env/src/command
'
{
declare
module
.
exports
:
any
;
}
declare
module
'
cross-env/src
'
{
declare
module
.
exports
:
any
;
}
declare
module
'
cross-env/src/is-windows
'
{
declare
module
.
exports
:
any
;
}
declare
module
'
cross-env/src/variable
'
{
declare
module
.
exports
:
any
;
}
// Filename aliases
declare
module
'
cross-env/src/bin/cross-env-shell.js
'
{
declare
module
.
exports
:
$Exports
<
'
cross-env/src/bin/cross-env-shell
'
>
;
}
declare
module
'
cross-env/src/bin/cross-env.js
'
{
declare
module
.
exports
:
$Exports
<
'
cross-env/src/bin/cross-env
'
>
;
}
declare
module
'
cross-env/src/command.js
'
{
declare
module
.
exports
:
$Exports
<
'
cross-env/src/command
'
>
;
}
declare
module
'
cross-env/src/index
'
{
declare
module
.
exports
:
$Exports
<
'
cross-env/src
'
>
;
}
declare
module
'
cross-env/src/index.js
'
{
declare
module
.
exports
:
$Exports
<
'
cross-env/src
'
>
;
}
declare
module
'
cross-env/src/is-windows.js
'
{
declare
module
.
exports
:
$Exports
<
'
cross-env/src/is-windows
'
>
;
}
declare
module
'
cross-env/src/variable.js
'
{
declare
module
.
exports
:
$Exports
<
'
cross-env/src/variable
'
>
;
}
flow-typed/npm/flow-bin_v0.x.x.js
0 → 100644
View file @
3f2952f6
// flow-typed signature: defcb6d3fbb0946084b6113e14859c31
// flow-typed version: c6154227d1/flow-bin_v0.x.x/flow_>=v0.104.x
declare
module
"
flow-bin
"
{
declare
module
.
exports
:
string
;
}
flow-typed/npm/history_v4.10.x.js
0 → 100644
View file @
3f2952f6
// flow-typed signature: 0762e7fb3ed10546ca661396febcdbf5
// flow-typed version: 51319746df/history_v4.10.x/flow_>=v0.104.x
declare
module
'
history
'
{
declare
type
Unregister
=
()
=>
void
;
declare
export
type
Action
=
'
PUSH
'
|
'
REPLACE
'
|
'
POP
'
;
declare
export
type
Location
=
{
|
pathname
:
string
,
search
:
string
,
hash
:
string
,
state
:
{
...
},
key
:
string
,
|
};
declare
type
History
<
HistoryLocation
=
Location
>
=
{
|
length
:
number
,
location
:
HistoryLocation
,
action
:
Action
,
push
:
((
path
:
string
,
state
?:
{
...
})
=>
void
)
&
((
location
:
$Shape
<
HistoryLocation
>
)
=>
void
),
replace
:
((
path
:
string
,
state
?:
{
...
})
=>
void
)
&
((
location
:
$Shape
<
HistoryLocation
>
)
=>
void
),
go
(
n
:
number
):
void
,
goBack
():
void
,
goForward
():
void
,
listen
((
location
:
HistoryLocation
,
action
:
Action
)
=>
void
):
Unregister
,