From 56bb1806744fa6de4dfcad3a921210a177174139 Mon Sep 17 00:00:00 2001 From: James Farrell Date: Wed, 2 Dec 2020 12:21:33 +0100 Subject: [PATCH 01/12] WIP --- resolvers/projectResolver.ts | 3 ++- server/bootstrap.ts | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/resolvers/projectResolver.ts b/resolvers/projectResolver.ts index c56f3e4b4..1578311b9 100644 --- a/resolvers/projectResolver.ts +++ b/resolvers/projectResolver.ts @@ -141,10 +141,11 @@ export class ProjectResolver { @Query(returns => [Project]) async projects (@Args() { take, skip, admin }: GetProjectsArgs): Promise { - return this.projectRepository.find({ + const projects = await this.projectRepository.find({ where: { admin }, take, skip }) + return projects } @Query(returns => TopProjects) diff --git a/server/bootstrap.ts b/server/bootstrap.ts index 680129ddd..dfe7e1440 100644 --- a/server/bootstrap.ts +++ b/server/bootstrap.ts @@ -82,7 +82,23 @@ export async function bootstrap() { app.use(cors()) apolloServer.applyMiddleware({ app }); app.post('/stripe-webhook', bodyParser.raw({ type: 'application/json' }), handleStripeWebhook); - + app.get('/project', (req, res) => { + res.send({ + balance: 0, + id: 24, + title: 'James test project', + slug: 'James-test-project', + admin: '17', + description: 'This is a super cool description!!!!', + organisationId: 1212121212, + coOrdinates: '0.342434, 0.3434343', + image: 'https://ipfs.giveth.io/ipfs/QmYx4eCHQFLJNEKWLjFQGR8hisEtdDbYqGKHSmCWuRvufa', + impactLocation: null, + stripeAccountId: null, + walletAddress: '0xD2CAc44B9d072A0D6bD39482147d894f13C5CF32', + categories: ['carbon', 'biodiversity'] + }) + }) // Start the server app.listen({ port: 4000 }) console.log(`🚀 Server is running, GraphQL Playground available at http://127.0.0.1:${4000}/graphql`) From d9774b10888eecdace1df96adfd85427e3e15875 Mon Sep 17 00:00:00 2001 From: James Farrell Date: Thu, 3 Dec 2020 00:57:16 +0100 Subject: [PATCH 02/12] remove reaction code as its not used --- resolvers/projectResolver.ts | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/resolvers/projectResolver.ts b/resolvers/projectResolver.ts index c3b063e41..75fdbb074 100644 --- a/resolvers/projectResolver.ts +++ b/resolvers/projectResolver.ts @@ -413,35 +413,6 @@ export class ProjectResolver { return ProjectUpdate.save(update); } - @Mutation(returns => Boolean) - async toggleReaction ( - @Arg('updateId') updateId: number, - @Arg('reaction') reaction: PROJECT_UPDATE_REACTIONS = 'heart', - @Ctx() { req: { user } }: MyContext, - @PubSub() pubSub: PubSubEngine - ): Promise { - if (!user) throw new Error('Authentication required.') - - const update = await ProjectUpdate.findOne({ id: updateId }); - if (!update) throw new Error('Update not found.'); - - const currentReaction = await ProjectUpdateReactions.findOne({ userId: user.userId }); - - await ProjectUpdateReactions.delete({ userId: user.userId }); - - if (currentReaction && currentReaction.reaction === reaction) return false; - - const newReaction = await ProjectUpdateReactions.create({ - userId: user.userId, - projectUpdateId: update.id, - reaction - }) - - await ProjectUpdateReactions.save(newReaction) - - return true; - } - @Query(returns => [GetProjectUpdatesResult]) async getProjectUpdates ( @Arg('projectId') projectId: number, From 5c5db7be09e43d0cded133bdfba26226d2e7b0e1 Mon Sep 17 00:00:00 2001 From: James Farrell Date: Thu, 3 Dec 2020 01:07:43 +0100 Subject: [PATCH 03/12] Change seeds --- helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpers.ts b/helpers.ts index c5603ac76..927d43d33 100644 --- a/helpers.ts +++ b/helpers.ts @@ -52,9 +52,9 @@ export async function seedDatabase () { const icrcOrg = organisationRepository.create([ { - title: 'International Committee of the Red Cross (ICRC)', + title: 'CO2ken', description: - 'Established in 1863, the ICRC operates worldwide, helping people affected by conflict and armed violence and promoting the laws that protect victims of war. An independent and neutral organization, its mandate stems essentially from the Geneva Conventions of 1949. We are based in Geneva, Switzerland, and employ some 16,000 people in more than 80 countries. The ICRC is funded mainly by voluntary donations from governments and from National Red Cross and Red Crescent Societies.' + 'We tokenize carbon offsets to make them available for Ethereums web3 ecosystem.' }, { title: 'Giveth', From 28dc14aa6fb9ff853213a9b7dc625102b015bc89 Mon Sep 17 00:00:00 2001 From: James Farrell Date: Thu, 3 Dec 2020 01:11:03 +0100 Subject: [PATCH 04/12] push seeds back up --- server/createSchema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/createSchema.ts b/server/createSchema.ts index 8bf7ebc07..6e0f0003b 100644 --- a/server/createSchema.ts +++ b/server/createSchema.ts @@ -36,7 +36,7 @@ const createSchema = async (): Promise => { if (dropSeed) { // seed database with some data // Removed for go live, in future this can be used to init the db with data, such as seed projects or categories - // const { defaultUser } = await seedDatabase() + const { defaultUser } = await seedDatabase() } // build TypeGraphQL executable schema From 1e5663ed2a8b2d77912fd905f4486818079120a0 Mon Sep 17 00:00:00 2001 From: James Farrell Date: Thu, 3 Dec 2020 01:22:17 +0100 Subject: [PATCH 05/12] Put DB_DROP_SEED back into the config --- config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config.ts b/config.ts index 8eb5ae23c..d732a8e8f 100644 --- a/config.ts +++ b/config.ts @@ -1,6 +1,7 @@ import * as dotenv from 'dotenv' import * as path from 'path'; +console.log(`process.env.NODE_ENV ---> : ${process.env.NODE_ENV}`) dotenv.config({ path: path.resolve(__dirname, `./config/${process.env.NODE_ENV||''}.env`) }); const envVars = [ @@ -23,7 +24,8 @@ const envVars = [ 'STRIPE_WEBHOOK_SECRET', 'PINATA_API_KEY', 'PINATA_SECRET_API_KEY', - 'UPLOAD_MAX_FILE_SIZE' + 'UPLOAD_MAX_FILE_SIZE', + 'DB_DROP_SEED' ] class Config { From 86829bb5a65f03139cdba95c54307e4a0b7dd01f Mon Sep 17 00:00:00 2001 From: James Farrell Date: Thu, 3 Dec 2020 01:29:51 +0100 Subject: [PATCH 06/12] push new seeds --- helpers.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/helpers.ts b/helpers.ts index 927d43d33..ac635711e 100644 --- a/helpers.ts +++ b/helpers.ts @@ -39,17 +39,20 @@ export async function seedDatabase () { }) await userRepository.save([superAdminUser, icrcAdmin, ifrcAdmin]) - const covidProject = projectRepository.create({ - title: 'COVID-19: ICRC global response to the coronavirus', - description: `Professionals with a background in health, disaster management, water, sanitation, food and economic security, and logistics attended the 4th edition of the Regional HELP (Health Emergencies in Large Populations) course held in Delhi from 24 February to 6 March 2020. The two-week programme prepared participants, who came from nine countries, for effectively leading an emergency health response. - - In India, the HELP course is organized by the ICRC in partnership with International Institute of Health Management Research (IIHMR), National Institute of Disaster Management, World Health Organization (WHO) and the Indian Red Cross Society. It aims to enhance professionalism in health emergency response with an emphasis on decision-making. It uses the public health approach, fostering multidisciplinary responses and bringing out challenges, dilemmas, norms, standards and principles. This synergy between the field expertise of the ICRC and the academic expertise of IIHMR makes the course different from other HELP courses conducted around the world.` + const project1 = projectRepository.create({ + title: 'Ecoera', + description: `Become Climate Positive + We enable the Carbon Transformation by making your organisation go climate positive using carbon removal from our sustainable biochar carbon sink.`, + organisationId: 1 }) - console.log(`aProject1 : ${JSON.stringify(covidProject, null, 2)}`) - - await projectRepository.save(covidProject) - console.log(`aProject2 : ${JSON.stringify(covidProject, null, 2)}`) - + const project2 = projectRepository.create({ + title: 'REDD+ Papua New Guinea', + description: `Why only Offsett and Reduce your carbon footprint? Our Validated, Verified, and Registered Carbon Credits conserve endangered tropical rainforests in Papua New Guinea and generate historical economic growth and social transformation for its people.`, + organisationId: 1 + }) + + await projectRepository.save([project1, project2]) + const icrcOrg = organisationRepository.create([ { title: 'CO2ken', From 1ea574c42205f08944a8b0b742cdf315f31a6d8d Mon Sep 17 00:00:00 2001 From: James Farrell Date: Mon, 7 Dec 2020 15:28:49 +0100 Subject: [PATCH 07/12] Update admin, fix some issues --- entities/project.ts | 2 +- helpers.ts | 34 +++++++++++++++++++------------- resolvers/projectResolver.ts | 6 ++++++ resolvers/types/project-input.ts | 2 +- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/entities/project.ts b/entities/project.ts index 2231fdb77..2c0af210a 100644 --- a/entities/project.ts +++ b/entities/project.ts @@ -51,7 +51,7 @@ class Project extends BaseEntity { @Field({ nullable: true }) @Column({ nullable: true }) - admin?: string + admin?: number @Field({ nullable: true }) @Column({ nullable: true }) diff --git a/helpers.ts b/helpers.ts index ac635711e..8da7cf9a5 100644 --- a/helpers.ts +++ b/helpers.ts @@ -22,38 +22,44 @@ export async function seedDatabase () { confirmed: true, loginType: 'password' }) - const icrcAdmin = userRepository.create({ - email: 'icrcAdmin@icrcAdmin.com', - firstName: 'icrcAdmin', + // Organisation 1 + const co2kenAdmin = userRepository.create({ + email: 'admin@co2ken.io', + firstName: 'CO2ken', password: bcrypt.hashSync(seedPassword, 12), confirmed: true, loginType: 'password' }) - const ifrcAdmin = userRepository.create({ - email: 'ifrcAdmin@icrcAdmin.com', - firstName: 'ifrcAdmin', + const givethAdmin = userRepository.create({ + email: 'james@giveth.io', + firstName: 'givethAdmin', password: bcrypt.hashSync(seedPassword, 12), confirmed: true, loginType: 'password' }) - await userRepository.save([superAdminUser, icrcAdmin, ifrcAdmin]) + await userRepository.save([superAdminUser, co2kenAdmin, givethAdmin]) const project1 = projectRepository.create({ title: 'Ecoera', description: `Become Climate Positive We enable the Carbon Transformation by making your organisation go climate positive using carbon removal from our sustainable biochar carbon sink.`, - organisationId: 1 + organisationId: 2, + admin: 2, + walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5' }) const project2 = projectRepository.create({ title: 'REDD+ Papua New Guinea', description: `Why only Offsett and Reduce your carbon footprint? Our Validated, Verified, and Registered Carbon Credits conserve endangered tropical rainforests in Papua New Guinea and generate historical economic growth and social transformation for its people.`, - organisationId: 1 + organisationId: 2, + admin: 2, + walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5' + }) await projectRepository.save([project1, project2]) - const icrcOrg = organisationRepository.create([ + const testOrganizations = organisationRepository.create([ { title: 'CO2ken', description: @@ -70,18 +76,18 @@ export async function seedDatabase () { } ]) - await organisationRepository.save(icrcOrg) + await organisationRepository.save(testOrganizations) // Seed join table // const organisationProject = organisationProjectRepository.create({ - // organisation: icrcOrg[0], + // organisation: testOrganizations[0], // project: covidProject // }) // await organisationProjectRepository.save(organisationProject) const adminOrganisationUser = organisationUserRepository.create({ role: 'admin', - organisation: icrcOrg[0], - user: icrcAdmin + organisation: testOrganizations[0], + user: co2kenAdmin }) await organisationUserRepository.save(adminOrganisationUser) diff --git a/resolvers/projectResolver.ts b/resolvers/projectResolver.ts index 75fdbb074..0f952f5aa 100644 --- a/resolvers/projectResolver.ts +++ b/resolvers/projectResolver.ts @@ -192,9 +192,15 @@ export class ProjectResolver { ) { if (!user) throw new Error('Authentication required.') + console.log(`projectId ---> : ${projectId}`) const project = await Project.findOne({ id: projectId }); + + console.log(`project : ${JSON.stringify(project, null, 2)}`) + if (!project) throw new Error('Project not found.'); + console.log(`project.admin ---> : ${project.admin}`) + console.log('user.userId', user.userId) if (project.admin != user.userId) throw new Error('You are not the owner of this project.') for (const field in newProjectData) diff --git a/resolvers/types/project-input.ts b/resolvers/types/project-input.ts index dee71e4da..3e983379d 100644 --- a/resolvers/types/project-input.ts +++ b/resolvers/types/project-input.ts @@ -9,7 +9,7 @@ export class ProjectInput { title: string @Field({ nullable: true }) - admin?: string + admin?: number @Field({ nullable: true }) @Length(0, 255) From 6cedac0e18866a39c138532aa9fb56d132ba16cb Mon Sep 17 00:00:00 2001 From: James Farrell Date: Mon, 7 Dec 2020 15:30:32 +0100 Subject: [PATCH 08/12] Quick fix to remove console --- resolvers/projectResolver.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/resolvers/projectResolver.ts b/resolvers/projectResolver.ts index 0f952f5aa..07f24f83b 100644 --- a/resolvers/projectResolver.ts +++ b/resolvers/projectResolver.ts @@ -192,15 +192,10 @@ export class ProjectResolver { ) { if (!user) throw new Error('Authentication required.') - console.log(`projectId ---> : ${projectId}`) const project = await Project.findOne({ id: projectId }); - console.log(`project : ${JSON.stringify(project, null, 2)}`) - - if (!project) throw new Error('Project not found.'); - console.log(`project.admin ---> : ${project.admin}`) - console.log('user.userId', user.userId) + if (project.admin != user.userId) throw new Error('You are not the owner of this project.') for (const field in newProjectData) From 3f974959017fcb082a8001ba8e6d93f9e4b0ff06 Mon Sep 17 00:00:00 2001 From: James Farrell Date: Mon, 7 Dec 2020 15:38:48 +0100 Subject: [PATCH 09/12] Fix merge error --- server/createSchema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/createSchema.ts b/server/createSchema.ts index e3d8421a5..455f9085e 100644 --- a/server/createSchema.ts +++ b/server/createSchema.ts @@ -32,7 +32,7 @@ const createSchema = async (): Promise => { dropSchema, cache: true }) - + const dropSeed = config.get('DB_DROP_SEED') ? config.get('DB_DROP_SEED') : false if (dropSeed) { // seed database with some data // Removed for go live, in future this can be used to init the db with data, such as seed projects or categories From 90f72b70afdadcec26fa9237e68a012016e6b00f Mon Sep 17 00:00:00 2001 From: James Farrell Date: Mon, 7 Dec 2020 15:51:47 +0100 Subject: [PATCH 10/12] Update seeds, and add slug to project-input --- helpers.ts | 7 ++++--- resolvers/types/project-input.ts | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/helpers.ts b/helpers.ts index 8da7cf9a5..deb079356 100644 --- a/helpers.ts +++ b/helpers.ts @@ -46,15 +46,16 @@ export async function seedDatabase () { We enable the Carbon Transformation by making your organisation go climate positive using carbon removal from our sustainable biochar carbon sink.`, organisationId: 2, admin: 2, - walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5' + walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5', + slug: 'ecoera' }) const project2 = projectRepository.create({ title: 'REDD+ Papua New Guinea', description: `Why only Offsett and Reduce your carbon footprint? Our Validated, Verified, and Registered Carbon Credits conserve endangered tropical rainforests in Papua New Guinea and generate historical economic growth and social transformation for its people.`, organisationId: 2, admin: 2, - walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5' - + walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5', + slug: 'redd-papua-new-guinea' }) await projectRepository.save([project1, project2]) diff --git a/resolvers/types/project-input.ts b/resolvers/types/project-input.ts index 3e983379d..a260240ac 100644 --- a/resolvers/types/project-input.ts +++ b/resolvers/types/project-input.ts @@ -8,6 +8,9 @@ export class ProjectInput { @MaxLength(70) title: string + @Field({ nullable: true }) + slug?: string; + @Field({ nullable: true }) admin?: number From 555b90eabd9f129c369f8e60a72f4f0f4bc953d3 Mon Sep 17 00:00:00 2001 From: James Farrell Date: Mon, 7 Dec 2020 20:06:51 +0100 Subject: [PATCH 11/12] Seed images --- helpers.ts | 6 ++++-- resolvers/types/project-input.ts | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/helpers.ts b/helpers.ts index deb079356..0b97e00cf 100644 --- a/helpers.ts +++ b/helpers.ts @@ -47,7 +47,8 @@ export async function seedDatabase () { organisationId: 2, admin: 2, walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5', - slug: 'ecoera' + slug: 'ecoera', + image: 'https://cdn.shopify.com/s/files/1/2556/2892/files/BiokolBigbag_3000x.JPG?v=1511514366' }) const project2 = projectRepository.create({ title: 'REDD+ Papua New Guinea', @@ -55,7 +56,8 @@ export async function seedDatabase () { organisationId: 2, admin: 2, walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5', - slug: 'redd-papua-new-guinea' + slug: 'redd-papua-new-guinea', + image: 'https://offsetra.com/agrocortex_banner.jpg' }) await projectRepository.save([project1, project2]) diff --git a/resolvers/types/project-input.ts b/resolvers/types/project-input.ts index a260240ac..d9fec3abc 100644 --- a/resolvers/types/project-input.ts +++ b/resolvers/types/project-input.ts @@ -29,6 +29,9 @@ export class ProjectInput { @Field({ nullable: true }) imageStatic?: string + @Field({ nullable: true }) + image?: string; + @Field({ nullable: true }) impactLocation?: string From ef2b4f6d36abd29000f49bfeec25dd28ca8418de Mon Sep 17 00:00:00 2001 From: James Farrell Date: Wed, 30 Dec 2020 19:25:16 +0100 Subject: [PATCH 12/12] Giveth project as default entry in backend https://github.com/Giveth/giveth-2/issues/290 --- config.ts | 9 +- helpers.ts | 181 ++++++++++++++++++++++++++--------------- server/createSchema.ts | 2 +- user/LoginResolver.ts | 4 +- 4 files changed, 127 insertions(+), 69 deletions(-) diff --git a/config.ts b/config.ts index 8fd8b6bdf..225495be8 100644 --- a/config.ts +++ b/config.ts @@ -25,7 +25,11 @@ const envVars = [ 'PINATA_API_KEY', 'PINATA_SECRET_API_KEY', 'UPLOAD_MAX_FILE_SIZE', - 'DB_DROP_SEED' + 'DB_DROP_SEED', + 'SEED_PASSWORD', + 'SERVER_ADMIN', + 'DEFAULT_ORGANISATION', + 'UPLOAD_FILE_MAX_SIZE' ] class Config { @@ -65,6 +69,9 @@ class Config { } get (envVar: string): string | number { + if(!this[envVar]) { + throw new Error(`${envVar} is an invalid env variable`) + } return this[envVar] } } diff --git a/helpers.ts b/helpers.ts index 0b97e00cf..516ae2ff4 100644 --- a/helpers.ts +++ b/helpers.ts @@ -1,3 +1,4 @@ +import config from './config'; import { getRepository, Column, ColumnOptions } from 'typeorm' import * as bcrypt from 'bcryptjs' @@ -14,72 +15,129 @@ export async function seedDatabase () { // const organisationProjectRepository = getRepository(OrganisationProject) const userRepository = getRepository(User) - const seedPassword = 'qweqweqwe' + console.log(`config.get('SEED_PASSWORD') ---> : ${config.get('SEED_PASSWORD')}`) + const seedPassword = config.get('SEED_PASSWORD').toString() + const serverEmail = config.get('SERVER_ADMIN').toString() + let users: User[] = [] const superAdminUser = userRepository.create({ - email: 'jamespfarrell@gmail.com', - firstName: 'James', - password: bcrypt.hashSync(seedPassword, 12), - confirmed: true, - loginType: 'password' - }) - // Organisation 1 - const co2kenAdmin = userRepository.create({ - email: 'admin@co2ken.io', - firstName: 'CO2ken', + email: serverEmail, + firstName: 'admin', password: bcrypt.hashSync(seedPassword, 12), confirmed: true, loginType: 'password' }) - const givethAdmin = userRepository.create({ - email: 'james@giveth.io', - firstName: 'givethAdmin', - password: bcrypt.hashSync(seedPassword, 12), - confirmed: true, - loginType: 'password' - }) - await userRepository.save([superAdminUser, co2kenAdmin, givethAdmin]) - - const project1 = projectRepository.create({ - title: 'Ecoera', - description: `Become Climate Positive - We enable the Carbon Transformation by making your organisation go climate positive using carbon removal from our sustainable biochar carbon sink.`, - organisationId: 2, - admin: 2, - walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5', - slug: 'ecoera', - image: 'https://cdn.shopify.com/s/files/1/2556/2892/files/BiokolBigbag_3000x.JPG?v=1511514366' - }) - const project2 = projectRepository.create({ - title: 'REDD+ Papua New Guinea', - description: `Why only Offsett and Reduce your carbon footprint? Our Validated, Verified, and Registered Carbon Credits conserve endangered tropical rainforests in Papua New Guinea and generate historical economic growth and social transformation for its people.`, - organisationId: 2, - admin: 2, - walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5', - slug: 'redd-papua-new-guinea', - image: 'https://offsetra.com/agrocortex_banner.jpg' - }) - - await projectRepository.save([project1, project2]) + users.push(superAdminUser) + + let projects: Project[] = [] + let organisations: Organisation[] = [] - const testOrganizations = organisationRepository.create([ - { - title: 'CO2ken', - description: - 'We tokenize carbon offsets to make them available for Ethereums web3 ecosystem.' - }, - { + if(config.get('DEFAULT_ORGANISATION') === 'giveth' ) { + const givethAdmin = userRepository.create({ + email: 'james@giveth.io', + firstName: 'admin', + password: bcrypt.hashSync(seedPassword, 12), + confirmed: true, + loginType: 'password' + }) + users.push(givethAdmin) + await userRepository.save(users) + const project1 = projectRepository.create({ title: 'Giveth', - description: 'Giveth is the future of giving.' - }, - { - title: 'Gaia Protection', - description: - 'The Madre Tierra Verde Foundation aims to contribute to the transition of Costa Rican society towards a paradigm of a green and intelligent society, following the guidelines of the National Strategy for Decarbonizing the Economy, through guidance and advice to organizations, communities and governments.' - } - ]) - - await organisationRepository.save(testOrganizations) + description: `The future of Giving + Unlike traditional charity, with Giveth every donation and pledge is transparent, so you always know exactly where your donation went and get a good sense of the impact it made in direct communication with your beneficiary.`, + organisationId: 1, + admin: 2, + walletAddress: 'revolution.eth', + slug: 'giveth', + image: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiCiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIKICAgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxuczpzb2RpcG9kaT0iaHR0cDovL3NvZGlwb2RpLnNvdXJjZWZvcmdlLm5ldC9EVEQvc29kaXBvZGktMC5kdGQiCiAgIHhtbG5zOmlua3NjYXBlPSJodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy9uYW1lc3BhY2VzL2lua3NjYXBlIgogICB3aWR0aD0iMTkzMC4xNzMzIgogICBoZWlnaHQ9IjE5MzEuNjgyMSIKICAgdmlld0JveD0iMCAwIDUxMC42OTE2OCA1MTEuMDkwODgiCiAgIHZlcnNpb249IjEuMSIKICAgaWQ9InN2Zzg2MCIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMC45Mi4zICgyNDA1NTQ2LCAyMDE4LTAzLTExKSIKICAgc29kaXBvZGk6ZG9jbmFtZT0iZ2l2ZXRoLXN5bWJvbC1sb2dvLXB1cnBsZS5zdmciPgogIDxkZWZzCiAgICAgaWQ9ImRlZnM4NTQiP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ICAgICA8ZwogICAgICAgICBpZD0iZzE0IgogICAgICAgICBjbGlwLXBhdGg9InVybCgjY2xpcFBhdGgxOCkiCiAgICAgICAgIHN0eWxlPSJmaWxsOiMyZjAzNDA7ZmlsbC1vcGFjaXR5OjEiPgogICAgICAgIDxnCiAgICAgICAgICAgaWQ9ImcyMCIKICAgICAgICAgICBzdHlsZT0iZmlsbDojMmYwMzQwO2ZpbGwtb3BhY2l0eToxIgogICAgICAgICAgIHRyYW5zZm9ybT0ibWF0cml4KDEsMCwwLDAuNzA2MzcwOTEsMCw2MDIuMjMwMzMpIj4KICAgICAgICAgIDxnCiAgICAgICAgICAgICBpZD0iZzIyIgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzJmMDM0MDtmaWxsLW9wYWNpdHk6MSIgLz4KICAgICAgICAgIDxnCiAgICAgICAgICAgICBpZD0iZzMyIgogICAgICAgICAgICAgc3R5bGU9ImZpbGw6IzJmMDM0MDtmaWxsLW9wYWNpdHk6MSI+CiAgICAgICAgICAgIDxnCiAgICAgICAgICAgICAgIGNsaXAtcGF0aD0idXJsKCNjbGlwUGF0aDI2KSIKICAgICAgICAgICAgICAgaWQ9ImczMCIKICAgICAgICAgICAgICAgc3R5bGU9Im9wYWNpdHk6MDtmaWxsOiMyZjAzNDA7ZmlsbC1vcGFjaXR5OjEiPgogICAgICAgICAgICAgIDxwYXRoCiAgICAgICAgICAgICAgICAgZD0iTSAwLDIwNTAuOTkyIEggMTQ0Ny42MzIgViAwIEggMCBaIgogICAgICAgICAgICAgICAgIHN0eWxlPSJmaWxsOiMyZjAzNDA7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiCiAgICAgICAgICAgICAgICAgaWQ9InBhdGgyOCIKICAgICAgICAgICAgICAgICBpbmtzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIiAvPgogICAgICAgICAgICA8L2c+CiAgICAgICAgICA8L2c+CiAgICAgICAgPC9n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sbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiCiAgICAgICAgICAgICBpZD0icGF0aDQwIgogICAgICAgICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIgLz4KICAgICAgICA8L2c+CiAgICAgICAgPGcKICAgICAgICAgICBpZD0iZzQyIgogICAgICAgICAgIHRyYW5zZm9ybT0idHJhbnNsYXRlKDExMDguMzAzNywxNjE0LjE3MDIpIgogICAgICAgICAgIHN0eWxlPSJmaWxsOiMyZjAzNDA7ZmlsbC1vcGFjaXR5OjEiPgogICAgICAgICAgPHBhdGgKICAgICAgICAgICAgIGQ9Ik0gMCwwIEMgLTAuMDE0LDcyLjAwMiA1OC4zMzIsMTMwLjM5NiAxMzAuMzQ3LDEzMC40NSAyMDIuMzYsMTMwLjUwNiAyNjAuNzk0LDcyLjIwMiAyNjAuODg5LDAuMiAyNjAuOTg0LC03MS44MDIgMjAyLjcwNCwtMTMwLjI2IDEzMC42OSwtMTMwLjM5NCA5Ni4wMzIsLTEzMC41NCA2Mi43NDgsLTExNi44NTYgMzguMjE0LC05Mi4zOCAxMy42ODMsLTY3LjkwMiAtMC4wNzEsLTM0LjY1MiAwLDAiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojMmYwMzQwO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIgogICAgICAgICAgICAgaWQ9InBhdGg0NCIKICAgICAgICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiIC8+CiAgICAgICAgPC9nPgogICAgICA8L2c+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K' + }) + projects.push(project1) + organisations = organisationRepository.create([ + { + title: 'Giveth', + description: 'Giveth is the future of giving.' + }, + { + title: 'Gaia Protection', + description: + 'The Madre Tierra Verde Foundation aims to contribute to the transition of Costa Rican society towards a paradigm of a green and intelligent society, following the guidelines of the National Strategy for Decarbonizing the Economy, through guidance and advice to organizations, communities and governments.' + } + ]) + await organisationRepository.save(organisations) + const adminOrganisationUser = organisationUserRepository.create({ + role: 'admin', + organisation: organisations[0], + user: givethAdmin + }) + console.log(`adminOrganisationUser : ${JSON.stringify(adminOrganisationUser, null, 2)}`) + + await organisationUserRepository.save(adminOrganisationUser) + } else { + // Organisation 1 + const co2kenAdmin = userRepository.create({ + email: 'admin@co2ken.io', + firstName: 'CO2ken', + password: bcrypt.hashSync(seedPassword, 12), + confirmed: true, + loginType: 'password' + }) + users.push(co2kenAdmin) + await userRepository.save(users) + const project1 = projectRepository.create({ + title: 'Ecoera', + description: `Become Climate Positive + We enable the Carbon Transformation by making your organisation go climate positive using carbon removal from our sustainable biochar carbon sink.`, + organisationId: 2, + admin: 2, + walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5', + slug: 'ecoera', + image: 'https://cdn.shopify.com/s/files/1/2556/2892/files/BiokolBigbag_3000x.JPG?v=1511514366' + }) + const project2 = projectRepository.create({ + title: 'REDD+ Papua New Guinea', + description: `Why only Offsett and Reduce your carbon footprint? Our Validated, Verified, and Registered Carbon Credits conserve endangered tropical rainforests in Papua New Guinea and generate historical economic growth and social transformation for its people.`, + organisationId: 2, + admin: 2, + walletAddress: '0x63A32F1595a68E811496D820680B74A5ccA303c5', + slug: 'redd-papua-new-guinea', + image: 'https://offsetra.com/agrocortex_banner.jpg' + }) + projects.push(project1) + projects.push(project2) + + organisations = organisationRepository.create([ + { + title: 'CO2ken', + description: + 'We tokenize carbon offsets to make them available for Ethereums web3 ecosystem.' + }, + { + title: 'Giveth', + description: 'Giveth is the future of giving.' + }, + { + title: 'Gaia Protection', + description: + 'The Madre Tierra Verde Foundation aims to contribute to the transition of Costa Rican society towards a paradigm of a green and intelligent society, following the guidelines of the National Strategy for Decarbonizing the Economy, through guidance and advice to organizations, communities and governments.' + } + ]) + await organisationRepository.save(organisations) + const adminOrganisationUser = organisationUserRepository.create({ + role: 'admin', + organisation: organisations[0], + user: co2kenAdmin + }) + await organisationUserRepository.save(adminOrganisationUser) + } + + + + await projectRepository.save(projects) + + + + // Seed join table // const organisationProject = organisationProjectRepository.create({ // organisation: testOrganizations[0], @@ -87,12 +145,7 @@ export async function seedDatabase () { // }) // await organisationProjectRepository.save(organisationProject) - const adminOrganisationUser = organisationUserRepository.create({ - role: 'admin', - organisation: testOrganizations[0], - user: co2kenAdmin - }) - await organisationUserRepository.save(adminOrganisationUser) + // const icrcProjects = projectRepository.create([ // { diff --git a/server/createSchema.ts b/server/createSchema.ts index 455f9085e..d0cf022a6 100644 --- a/server/createSchema.ts +++ b/server/createSchema.ts @@ -23,7 +23,7 @@ const createSchema = async (): Promise => { database: config.get('TYPEORM_DATABASE_NAME') as string, username: config.get('TYPEORM_DATABASE_USER') as string, password: config.get('TYPEORM_DATABASE_PASSWORD') as string, - port: config.get('PORT') as number, + port: config.get('TYPEORM_DATABASE_PORT') as number, host: config.get('TYPEORM_DATABASE_HOST') as string, entities, synchronize: true, diff --git a/user/LoginResolver.ts b/user/LoginResolver.ts index e4ce60815..a11e092d4 100644 --- a/user/LoginResolver.ts +++ b/user/LoginResolver.ts @@ -135,10 +135,8 @@ export class LoginResolver { avatar }).save() - console.log(`user saved : ${JSON.stringify(user, null, 2)}`) } else { - console.log('user exists already') - + user.avatar = avatar; if(name) user.name = name; await user.save();