Shorten, create and share memorable links for IBANS
Shorten IBAN numbers with url such as :
- iban.im/user/alias
- iban.im/fakturk/garanti
- Go
- GraphQL : graphql-go
- ORM : gorm
- New users should Sign Up & Sign In
- Change a Password of user
- Change a Profile of user
- Delete a Profile of user
- Get Profile of user
- New IBAN add for user
- Update IBAN for user
- Delete IBAN for user
- Get IBAN's of user
- When adding new IBAN check if is it exist with same name (we can add with different names)
- A user should add iban to only itself
- Create a database
postgres=# CREATE DATABASE ibanim;
- Create a user as owner of database
postgres=# CREATE USER ibanim WITH ENCRYPTED PASSWORD 'ibanim';
postgres=# ALTER DATABASE ibanim OWNER TO ibanim;
- Grant all privileges to user for the database
postgres=# GRANT ALL PRIVILEGES ON DATABASE ibanim TO ibanim;
- Configure the db in
db.go
// ConnectDB : connecting DB
func ConnectDB() (*DB, error) {
db, err := gorm.Open("postgres", "host=localhost port=5432 user=ibanim dbname=ibanim password=ibanim sslmode=disable")
if err != nil {
panic(err)
}
return &DB{db}, nil
}
or with Docker
host address should be edited to
host.docker.internal
to connect a host interface.
// ConnectDB : connecting DB
func ConnectDB() (*DB, error) {
db, err := gorm.Open("postgres", "host=host.docker.internal port=5432 user=ibanim dbname=ibanim password=ibanim sslmode=disable")
if err != nil {
panic(err)
}
return &DB{db}, nil
}
$ go run ./migrations/init.go
or with Docker
$ docker build -t ibanim .
$ docker run --rm ibanim migrate
This will generate the users
table in the database as per the User Model declared in ./model/user.go
$ go run server.go
or with Docker
$ docker run --rm -d -p 8080:8080 ibanim
Connect to http://localhost:8080
You need to set the Http request headers Authorization
: {JWT_token}
mutation {
signUp(
email: "[email protected]"
password: "12345678"
firstName: "graphql"
lastName: "go"
handle:"test"
) {
ok
error
user {
id
handle
email
firstName
lastName
bio
avatar
createdAt
updatedAt
}
}
}
mutation {
signIn(email: "[email protected]", password: "12345678") {
ok
error
token
}
}
mutation {
changePassword(password: "87654321") {
ok
error
user {
id
handle
email
firstName
lastName
bio
avatar
createdAt
updatedAt
}
}
}
mutation {
changeProfile(bio: "Go developer", avatar: "go-developer.png") {
ok
error
user {
id
handle
email
firstName
lastName
bio
avatar
createdAt
updatedAt
}
}
}
query {
getMyProfile {
ok
error
user {
id
handle
email
firstName
lastName
bio
avatar
createdAt
updatedAt
}
}
}
mutation {
ibanNew(text:"TR320010009999901234567890",password:"fatih",handle:"fakturk"){
ok
error
iban{
id
handle
text
password
createdAt
updatedAt
}
}
}
mutation {
ibanUpdate(text:"TR420010009999901234567891",password:"fatih",handle:"garanti"){
ok
error
iban{
id
handle
text
password
createdAt
updatedAt
}
}
}
query {
getMyIbans {
ok
error
iban {
id
handle
text
password
createdAt
updatedAt
ownerId
}
}
}