Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
form-creator-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
simmctic
form-creator
form-creator-api
Commits
b6d3913c
Commit
b6d3913c
authored
Apr 10, 2019
by
Matheus Horstmann
🐴
Committed by
Lucas Fernandes de Oliveira
Apr 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#15
: Create database middlewares
Signed-off-by:
Matheus Horstmann
<
mch15@inf.ufpr.br
>
parent
13457ba9
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
174 additions
and
167 deletions
+174
-167
CHANGELOG.md
CHANGELOG.md
+5
-0
package.json
package.json
+1
-1
src/api/apiTypes.ts
src/api/apiTypes.ts
+3
-3
src/api/controllers/item.spec.ts
src/api/controllers/item.spec.ts
+156
-156
src/api/middlewares/dbHandler.ts
src/api/middlewares/dbHandler.ts
+8
-6
src/main.ts
src/main.ts
+1
-1
No files found.
CHANGELOG.md
View file @
b6d3913c
...
...
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[
Semantic Versioning
](
https://semver.org/spec/v2.0.0.html
)
.
## 0.0.7 - 10-04-2019
### Changed
-
main.ts to include dbHandler Middleware and remove dummie class
### Added
-
Create dbHandler Middleware to be abble to access by routes #15 (Horstmann)
## 0.0.6 - 01-04-2019
### Changed
-
Input class to match with database model (Add id and description) (Horstmann)
...
...
package.json
View file @
b6d3913c
{
"name"
:
"form-creator-api"
,
"version"
:
"0.0.
6
"
,
"version"
:
"0.0.
7
"
,
"description"
:
"RESTful API used to manage and answer forms."
,
"main"
:
"index.js"
,
"scripts"
:
{
...
...
src/api/apiTypes.ts
View file @
b6d3913c
...
...
@@ -20,7 +20,7 @@
*/
import
*
as
express
from
"
express
"
;
import
{
Collection
}
from
"
../core/collection
"
;
import
{
DbHandler
}
from
"
../utils/dbHandler
"
;
/**
* Extension of Express requests that suports the addition
...
...
@@ -31,8 +31,8 @@ import { Collection } from "../core/collection";
* return a error the extension must be made.
*/
export
interface
Request
extends
express
.
Request
{
/** A
collection object. Simulate a database.
*/
collection
:
Collection
;
/** A
Database handler instace
*/
db
:
DbHandler
;
}
/**
...
...
src/api/controllers/item.spec.ts
View file @
b6d3913c
This diff is collapsed.
Click to expand it.
src/api/middlewares/
collection
.ts
→
src/api/middlewares/
dbHandler
.ts
View file @
b6d3913c
...
...
@@ -19,18 +19,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import
{
Collection
}
from
"
../../core/collection
"
;
import
{
configs
}
from
"
../../utils/config
"
;
import
{
DbHandler
}
from
"
../../utils/dbHandler
"
;
import
{
Middleware
}
from
"
../apiTypes
"
;
/**
* Creates a engine and middleware that
* inserts the
collection
into the request objects.
* inserts the
handler
into the request objects.
*/
export
function
CollectionMw
():
Middleware
{
const
collection
:
Collection
=
new
Collection
();
return
function
collectionMiddleware
(
req
,
res
,
next
)
{
req
.
collection
=
collection
;
export
function
DbHandlerMw
():
Middleware
{
const
db
:
DbHandler
=
new
DbHandler
(
configs
.
poolconfig
);
return
function
dbHandlerMiddleware
(
req
,
res
,
next
)
{
req
.
db
=
db
;
next
();
};
}
src/main.ts
View file @
b6d3913c
...
...
@@ -36,7 +36,7 @@ const app = module.exports = express();
const
port
=
process
.
env
.
PORT
;
// Include middlewares
import
{
CollectionMw
}
from
"
./api/middlewares/collection
"
;
import
{
DbHandlerMw
}
from
"
./api/middlewares/dbHandler
"
;
// Include controllers
import
{
ItemCtrl
}
from
"
./api/controllers/item
"
;
...
...
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